initial commit

master
Dominic Reich 4 years ago
commit 1c094833ba

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Dominic Reich, OE7DRT <oe7drt@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@ -0,0 +1,4 @@
# My personal hotspot dashboard
Using this for YSF and DMR+.

@ -0,0 +1,35 @@
<?php
/*
* conf.php
* Dashboard for my personal hotspot dashboard
* Configuration file
* Dominic Reich, OE7DRT, oe7drt@oevsv.at
*/
/* General Settings */
define('CALLSIGN', 'OE7DRT');
define('DMRID_DAT', '/home/pi/dmrid.dat');
define('MAXENTRIES', 15);
/* Brandmeister specific settings */
/* Well, I used this in my first version */
// define("BM_INI", "/etc/MMDVM-BM.ini");
// define("BM_PREFIX", "DMRHost-BM");
// define("BM_LOGPATH", "/var/log/mmdvm");
/* IPSC2 specific settings */
define("IPSC_INI", "/etc/MMDVM-IPSC.ini");
define("IPSC_PREFIX", "DMRHost-IPSC");
define("IPSC_LOGPATH", "/var/log/mmdvm");
/* YSF specific settings */
define("MMDVMHOST_INI", "/etc/MMDVM-YSF.ini");
define("MMDVMHOST_PREFIX", "MMDVM");
define("MMDVMHOST_LOGPATH", "/var/log/mmdvm");
define("YSFGW_INI", "/etc/YSFGateway.ini");
define("YSFGW_PREFIX", "YSFGateway");
define("YSFGW_LOGPATH", "/var/log/mmdvm");
?>

@ -0,0 +1,189 @@
#container {
/*max-width: 1200px;*/
text-align: left;
margin: auto;
background : #ffffff;
border-radius: 5px 5px 5px 5px;
-moz-border-radius: 5px 5px 5px 5px;
-webkit-border-radius: 5px 5px 5px 5px;
-khtml-border-radius: 5px 5px 5px 5px;
-ms-border-radius: 5px 5px 5px 5px;
box-shadow: 3px 3px 3px #707070;
}
#header {
background : #2d2d2d;
text-decoration : none;
color : #ffffff;
/*font-family : verdana, arial, sans-serif;*/
font-family : monospace;
font-size: 1.1em;
text-align : left;
padding : 5px 5px 5px 5px;
border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0px 0px;
-webkit-border-radius: 5px 5px 0px 0px;
-khtml-border-radius: 5px 5px 0px 0px;
-ms-border-radius: 5px 5px 0px 0px;
overflow-wrap: break-word;
}
#header h1 {
font-family: verdana, arial, sans-serif;
color: whitesmoke;
}
#content {
padding : 5px 5px 5px 5px;
color : #000000;
background : #ffffff;
text-align: center;
font-size: 1.4em;
/*overflow: hidden;*/
max-width: 100%;
}
#toptable {
/*margin-bottom: 0.5em;*/
width: 100%;
}
#bmtable {
float: left;
width: 49%;
margin-left: 1px;
margin-right: 1px;
}
#ipsctable {
float: right;
width: 49%;
margin-left: 1px;
margin-right: 1px;
}
#footer {
background : #2d2d2d;
text-decoration : none;
color : #ffffff;
font-family : verdana, arial, sans-serif;
font-size : 9px;
text-align : center;
padding : 10px 5px 10px 5px;
border-radius: 0 0 5px 5px;
-moz-border-radius: 0px 0px 5px 5px;
-webkit-border-radius: 0px 0px 5px 5px;
-khtml-border-radius: 0px 0px 5px 5px;
-ms-border-radius: 0px 0px 5px 5px;
clear : both;
overflow-wrap: break-word;
}
body, font {
background: #edf0f5;
font: 12px verdana,arial,sans-serif;
/*color: #ffffff;*/
color: #000000;
}
table {
/*vertical-align: middle;*/
text-align: center;
empty-cells: show;
padding-left: 0px;
padding-right: 0px;
padding-top: 0px;
padding-bottom: 0px;
border-collapse:collapse;
border-color: #000000;
border-style: solid;
/*border-spacing: 4px;
border-width: 2px;*/
text-decoration: none;
color: #ffffff;
background: #000000;
font-family: verdana,arial,sans-serif;
/*width: 100%;*/
/* white-space: nowrap;
overflow-x: scroll; */
}
table th {
font-family: "Lucidia Console",Monaco,monospace;
text-shadow: 1px 1px #3d3d3d;
text-decoration: none;
background: #2d2d2d;
/*border: 1px solid #c0c0c0;*/
border: 1px solid #000000;
}
table tr:nth-child(even) {
background: #f7f7f7;
}
table tr:nth-child(odd) {
background: #d0d0d0;
}
table td {
vertical-align: text-top;
color: #000000;
font-family: "Lucidia Console",Monaco,monospace;
text-decoration: none;
border: 1px solid #000000;
}
a {
text-decoration:none;
}
a:link, a:visited {
text-decoration: none;
color: #0000e0;
font-weight: normal;
}
ul {
padding: 5px;
margin: 10px 0;
list-style: none;
float: left;
}
ul li {
float: left;
display: inline; /*For ignore double margin in IE6*/
margin: 0 10px;
}
ul li a {
text-decoration: none;
float:left;
color: #999;
cursor: pointer;
font: 900 14px/22px "Arial", Helvetica, sans-serif;
}
ul li a span {
margin: 0 10px 0 -10px;
padding: 1px 8px 5px 18px;
position: relative; /*To fix IE6 problem (not displaying)*/
float:left;
}
h1 {
text-shadow: 2px 2px #000000;
text-align: center;
}
.box {
margin-top: 1em;
margin-bottom: 0.5em;
margin-left: 1px;
margin-right: 1px;
}
.clear {
clear: both;
}

1
dash.min.css vendored

@ -0,0 +1 @@
#container{text-align:left;margin:auto;background:#fff;border-radius:5px 5px 5px 5px;-moz-border-radius:5px 5px 5px 5px;-webkit-border-radius:5px 5px 5px 5px;-khtml-border-radius:5px 5px 5px 5px;-ms-border-radius:5px 5px 5px 5px;box-shadow:3px 3px 3px #707070}#header{background:#2d2d2d;text-decoration:none;color:#fff;font-family:monospace;font-size:1.1em;text-align:left;padding:5px 5px 5px 5px;border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;-webkit-border-radius:5px 5px 0 0;-khtml-border-radius:5px 5px 0 0;-ms-border-radius:5px 5px 0 0;overflow-wrap:break-word}#header h1{font-family:verdana,arial,sans-serif;color:whitesmoke}#content{padding:5px 5px 5px 5px;color:#000;background:#fff;text-align:center;font-size:1.4em;max-width:100%}#toptable{width:100%}#bmtable{float:left;width:49%;margin-left:1px;margin-right:1px}#ipsctable{float:right;width:49%;margin-left:1px;margin-right:1px}#footer{background:#2d2d2d;text-decoration:none;color:#fff;font-family:verdana,arial,sans-serif;font-size:9px;text-align:center;padding:10px 5px 10px 5px;border-radius:0 0 5px 5px;-moz-border-radius:0 0 5px 5px;-webkit-border-radius:0 0 5px 5px;-khtml-border-radius:0 0 5px 5px;-ms-border-radius:0 0 5px 5px;clear:both;overflow-wrap:break-word}body,font{background:#edf0f5;font:12px verdana,arial,sans-serif;color:#000}table{text-align:center;empty-cells:show;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;border-collapse:collapse;border-color:#000;border-style:solid;text-decoration:none;color:#fff;background:#000;font-family:verdana,arial,sans-serif}table th{font-family:"Lucidia Console",Monaco,monospace;text-shadow:1px 1px #3d3d3d;text-decoration:none;background:#2d2d2d;border:1px solid #000}table tr:nth-child(even){background:#f7f7f7}table tr:nth-child(odd){background:#d0d0d0}table td{vertical-align:text-top;color:#000;font-family:"Lucidia Console",Monaco,monospace;text-decoration:none;border:1px solid #000}a{text-decoration:none}a:link,a:visited{text-decoration:none;color:#0000e0;font-weight:normal}ul{padding:5px;margin:10px 0;list-style:none;float:left}ul li{float:left;display:inline;margin:0 10px}ul li a{text-decoration:none;float:left;color:#999;cursor:pointer;font:900 14px/22px "Arial",Helvetica,sans-serif}ul li a span{margin:0 10px 0 -10px;padding:1px 8px 5px 18px;position:relative;float:left}h1{text-shadow:2px 2px #000;text-align:center}.box{margin-top:1em;margin-bottom:.5em;margin-left:1px;margin-right:1px}.clear{clear:both}

@ -0,0 +1,549 @@
<?php
/*
* func.php
* Dashboard for my personal hotspot dashboard
* Functions file
* Dominic Reich, OE7DRT, oe7drt@oevsv.at
*/
function getBMInfo() {
$iniFile = BM_INI;
$logline = `grep "DMR Network" $iniFile -A 10 | egrep "^Address"`;
$addressLine = explode( "=", $logline );
$logline = `grep "DMR Network" $iniFile -A 10 | egrep "^Port"`;
$portLine = explode( "=", $logline );
$logline = `egrep "^\[DMR]$" $iniFile -A 30 | egrep "^Id="`;
$idLine = explode( "=", $logline );
$rpt_id = $idLine[1];
if( `command -v nslookup` ) {
$address = strstr( `nslookup $addressLine[1]`, "=" );
$dns = substr( $address, 2, strrpos( $address, "." ) - 2);
//echo "Master: $dns on Port: " . trim( $portLine[1] );
echo "<td>$dns</td>\n <td>" . trim( $portLine[1] ) . "</td>\n";
} else {
//echo "Master: " . trim( $addressLine[1] ) . ":" . trim( $portLine[1] );
echo "<td>" . trim( $addressLine[1] ) . "</td>\n <td>" . trim( $portLine[1] ) . "</td>\n";
}
echo "<td><a href=\"https://brandmeister.network/?page=repeater&id=$rpt_id\" target=\"_blank\">$rpt_id</a></td>\n";
}
function getIPSCInfo() {
$iniFile = IPSC_INI;
$logline = `grep "DMR Network" $iniFile -A 10 | egrep "^Address"`;
$addressLine = explode( "=", $logline );
// $logline = `grep "DMR Network" $iniFile -A 10 | egrep "^Port"`;
// $portLine = explode( "=", $logline );
$logline = `egrep "^\[DMR]$" $iniFile -A 30 | egrep "^Id="`;
$idLine = explode( "=", $logline );
$rpt_id = $idLine[1];
echo "<td>$rpt_id</td>\n";
// if( `command -v nslookup` ) {
// $address = strstr( `nslookup $addressLine[1]`, "=" );
// $dns = substr( $address, 2, strrpos( $address, "." ) - 2);
// //echo "Master: $dns on Port: " . trim( $portLine[1] );
// echo "<td>$dns</td>\n <td>" . trim( $portLine[1] ) . "</td>\n";
// } else {
//echo "Master: " . trim( $addressLine[1] ) . ":" . trim( $portLine[1] );
echo "<td>" . trim( $addressLine[1] ) . "</td>\n";
// echo " <td>" . trim( $portLine[1] ) . "</td>\n";
// }
$logline = `egrep -h "^Options=\"" $iniFile | tail -n 1`;
if( !empty( $logline )) {
$optionsLine = explode( "\"", $logline );
$options = explode( ";", $optionsLine[1] );
echo "<td style=\"word-break:break-word;\">";
foreach( $options as $option ) {
echo "$option ";
}
} else {
echo "<td>N/A</td>";
}
echo "</td>\n";
}
function countDGIDs( $iniFile = YSFGW_INI ) {
$logline = `grep "[Network]" $iniFile -A 10 | egrep "^Options"`;
$optionsLine = explode( "=", $logline );
$DGIDs = explode( ",", $optionsLine[1] );
return count( $DGIDs );
}
function getYSFInfo() {
$iniFile = YSFGW_INI;
$logline = `grep "[General]" $iniFile -A 10 | egrep "^Id"`;
$idLine = explode( "=", $logline );
$logline = `grep "[Network]" $iniFile -A 10 | egrep "^Startup"`;
$startupLine = explode( "=", $logline );
$logline = `grep "[Network]" $iniFile -A 10 | egrep "^Options"`;
$optionsLine = explode( "=", $logline );
$DGIDs = explode( ",", $optionsLine[1] );
echo "<td>" . trim( $idLine[1] ) . "</td>\n";
echo "<td>" . trim( $startupLine[1] ) . "</td>\n<td>";
foreach( $DGIDs as $DGID ) {
echo "$DGID ";
}
echo "</td>\n";
}
function getUptime() {
$uptime = intval( `cat /proc/uptime | awk '{ print $1 }'` );
if( $uptime >= 60 ) {
// in minutes
$minutes = intval( $uptime / 60 );
$seconds = $uptime % 60;
if( $minutes >= 60 ) {
$hours = intval( $minutes / 60 );
$minutes = $minutes % 60;
if( $hours >= 24 ) {
$days = intval( $hours / 24 );
$hours = $hours % 24;
$out = "${days}d ${hours}h ${minutes}m and ${seconds}s";
} else {
// no days, only hours minutes and seconds
$out = "${hours}h ${minutes}m and ${seconds}s";
}
} else {
// mintes < 60 only minuts, hours
$out = "${minutes}m and ${seconds}s";
}
} else {
// only seconds
$out = "${uptime}s";
}
return $out;
}
function ImportDB() {
$contents = array();
if( $file = fopen( DMRID_DAT, 'r' )) {
if( !defined("NONAMES")) {
while( !feof( $file )) {
$line = fgetss( $file, 64 );
$elem = explode( ";", $line );
array_push( $contents, $elem );
}
}
fclose( $file );
}
return $contents;
}
function CallsignLookupDB( $id ) {
// $call = "<a href=\"https://www.radioid.net/database/view?id=$call\"" . " target=\"_blank\">$call</a>";
global $mem;
if( !empty( $mem )) {
foreach( $mem as $key => $val ) {
if( $val[0] === $id ) {
$call = $mem[$key];
$callsign = $call[1];
$call_code = "<a href=\"https://qrz.com/db/$callsign\"" . " target=\"_blank\">$callsign</a>";
return $call_code;
}
}
}
$call_code = "<a href=\"https://www.radioid.net/database/view?id=$id\"" . " target=\"_blank\">$id</a>";
return $call_code;
}
function linkCallsign( $callsign ) {
$tmp = explode( "-", $callsign );
$call = trim( $tmp[0] );
$suffix = ( !empty( $tmp[1] ))
? "-$tmp[1]"
: "";
if( !empty( $suffix )) {
$suffix="-$suffix";
}
if( !is_numeric( $call )) {
$call = "<a href=\"https://qrz.com/db/$call\" target=\"_blank\">$call" . "</a>$suffix";
} elseif( strlen( $call ) == 7 ) {
// old version linked to ham-digital which now is fusioned into radioid.net
//$call = "<a href=\"https://ham-digital.org/dmr-userreg.php?usrid=$call\"" . " target=\"_blank\">$call</a>";
$call = CallsignLookupDB( $call );
} elseif( strlen( $call ) == 6 ) {
$call = "<a href=\"https://www.radioid.net/map?locator=$call\"" . " target=\"_blank\">$call</a>";
} elseif( strlen( $call ) == 4 ) {
//$call = "Reflector $call";
}
return $call;
}
function linkTG( $tg, $linktg ) {
if( !is_numeric( $tg ) && $linktg == "bm") {
$tmp = explode( " ", $tg );
$tg_id = trim( $tmp[1] );
$tg_new = "<a href=\"https://brandmeister.network/?page=lh&DestinationID=$tg_id\" target=\"_blank\">$tg</a>";
return $tg_new;
}
return $tg;
}
function rssiCalcImg( $val ) {
if( $val > -53 ) $rssi = "<img title=\"S9 +40dB\" alt=\"S9 +40dB\" src=\"img/4.png\">";
else if( $val > -63 ) $rssi = "<img title=\"S9 +30dB\" alt=\"S9 +30dB\" src=\"img/4.png\">";
else if( $val > -73 ) $rssi = "<img title=\"S9 +20dB\" alt=\"S9 +20dB\" src=\"img/4.png\">";
else if( $val > -83 ) $rssi = "<img title=\"S9 +10dB\" alt=\"S9 +10dB\" src=\"img/4.png\">";
else if( $val > -93 ) $rssi = "<img title=\"S9\" alt=\"S9\" src=\"img/4.png\">";
else if( $val > -99 ) $rssi = "<img title=\"S8\" alt=\"S8\" src=\"img/3.png\">";
else if( $val > -105 ) $rssi = "<img title=\"S7\" alt=\"S7\" src=\"img/3.png\">";
else if( $val > -111 ) $rssi = "<img title=\"S6\" alt=\"S6\" src=\"img/2.png\">";
else if( $val > -117 ) $rssi = "<img title=\"S5\" alt=\"S5\" src=\"img/2.png\">";
else if( $val > -123 ) $rssi = "<img title=\"S4\" alt=\"S4\" src=\"img/1.png\">";
else if( $val > -129 ) $rssi = "<img title=\"S3\" alt=\"S3\" src=\"img/1.png\">";
else if( $val > -135 ) $rssi = "<img title=\"S2\" alt=\"S2\" src=\"img/0.png\">";
else if( $val > -141 ) $rssi = "<img title=\"S1\" alt=\"S1\" src=\"img/0.png\">";
return "$rssi";
}
function rssiCalc( $val ) {
if( $val > -53 ) $rssi = "S9+40dB";
else if( $val > -63 ) $rssi = "S9+30dB";
else if( $val > -73 ) $rssi = "S9+20dB";
else if( $val > -83 ) $rssi = "S9+10dB";
else if( $val > -93 ) $rssi = "S9";
else if( $val > -99 ) $rssi = "S8";
else if( $val > -105 ) $rssi = "S7";
else if( $val > -111 ) $rssi = "S6";
else if( $val > -117 ) $rssi = "S5";
else if( $val > -123 ) $rssi = "S4";
else if( $val > -129 ) $rssi = "S3";
else if( $val > -135 ) $rssi = "S2";
else if( $val > -141 ) $rssi = "S1";
return "$rssi ($val dBm)";
}
function printTable( $id=0, $linktg, $time, $callsign, $slot, $tg, $duration, $loss = "---", $ber = "---" ) {
if( $duration >= 60 ) {
$min = str_pad( intval( $duration / 60 ), 2, "0", STR_PAD_LEFT );
$sec = str_pad( $duration % 60, 2, "0", STR_PAD_LEFT );
$duration = "$min:$sec";
} else {
$duration = "00:" . str_pad( $duration, 2, "0", STR_PAD_LEFT );
}
echo " <tr>\n" .
"<td align=\"right\">$id</td>\n" .
"<td>$time</td>\n" .
"<td>" . linkCallsign( $callsign ) ."</td>\n" .
"<td>$slot</td>\n" .
"<td>" . linkTG( $tg, $linktg ) . "</td>\n" .
"<td>$duration</td>\n" .
"<td>$loss</td>\n" .
"<td>$ber</td>\n" .
"</tr>\n";
}
// $linktg should be "bm" or false
function getLastHeard($logpath = BM_LOGPATH, $prefix = BM_PREFIX, $linktg = false, $limit = MAXENTRIES) {
$logPath = "$logpath/$prefix-*.log";
$logLines = explode( "\n", `egrep -h "DMR Slot" $logPath` );
$oldline = "";
$time = "";
$loss = "";
$ber = "";
$rssi = "";
$call = "";
$duration = "";
$repeater = "";
$printLines = [];
foreach( $logLines as $line ) {
if( empty( $oldline ) && strpos( $line, "network watchdog has expired" )) {
// $oldine=$line;
continue;
}
if( strpos( $line, "RF end of voice transmission" )) {
$time = date( "Y-m-d H:i:s", strtotime( substr( $line, 3, 24 )." UTC" ));
$callsign = substr( $line, 82, strpos( $line, "to" ) - 82 );
$slot = substr( $line, 36, strpos( $line, ",") -36);
$tg = substr( $line, 93, strpos( $line, ",", 93 ) - 93 );
$duration = round( trim( substr( $line, 103, strpos( $line, "seconds,", 103 ) - 103 ), " ," ));
$rssi_values = explode( "/", substr( $line, 133, strpos( $line, "dBm", 133 ) - 133 ));
$loss = rssiCalcImg( round( array_sum( $rssi_values ) / count( $rssi_values )));
$ber = substr( $line, 120, strpos( $line, ",", 120 ) - 120 );
if( empty( $ber )) $ber = "---";
} elseif( strpos( $line, "received network voice header" )) {
if( strpos( $oldline, "received network voice header" )) {
$oldline = $line;
continue;
} else {
$time = date( "Y-m-d H:i:s", strtotime( substr( $line, 3, 24 )." UTC" ));
$old_time = strtotime( $time );
$oldline=$line;
continue;
}
} elseif( strpos( $line, "received network end of voice" )) {
$time = date( "Y-m-d H:i:s", strtotime( substr( $line, 3, 24 )." UTC" ));
$callsign = substr( $line, 87, strpos( $line, "to ") - 87 );
$slot = substr( $line, 36, strpos( $line, ",") - 36);
$tg = substr(
$line,
strpos( $line, "to " ) + 3,
strpos( $line, ",", strpos( $line, "to " ) + 3 ) - strpos( $line, "to " ) - 3
);
$duration = substr(
$line,
strpos( $line, "to " ) + strlen( $tg ) + 5,
strpos( $line, " seconds," ) - strpos( $line, "to " ) - strlen( $tg ) - 5
);
$loss = substr(
$line,
strpos( $line, "seconds, " ) + 9,
strpos( $line, " packet loss" ) - strpos( $line, "seconds, " ) - 9
);
/*if( $loss == "0%" ) {
$loss = "-x-";
}*/
$ber = substr(
$line,
strpos( $line, "BER: " ) + 5,
strpos( $line, "%", strpos( $line, "BER: ")) - strpos( $line, "BER: " )
);
//if( $ber == "0.0%" ) $ber = "-x-";
$rssi = "";
} else {
continue;
}
// echo "<pre><code>\$callsign: $callsign at \$dgid: $dgid\n\$old_time: ".date("Y-m-d H:i:s", $old_time ).
// "\n\$new_time: ".date("Y-m-d H:i:s", $new_time )."</code></pre>\n";
// echo "<pre><code>OLD LINE: $oldline\nLINE: $line\n</code></pre>\n";
$tmp = [];
$tmp['linktg'] = $linktg;
$tmp['time'] = $time;
$tmp['callsign'] = $callsign;
$tmp['slot'] = $slot;
$tmp['tg'] = $tg;
$tmp['duration'] = round( $duration, 0, PHP_ROUND_HALF_UP );
$tmp['loss'] = $loss;
$tmp['ber'] = $ber;
array_unshift( $printLines, $tmp );
unset( $tmp );
// Lastly we set $oldline as the actual line
$oldline = $line;
}
$c = 0;
foreach( $printLines as $key=>$line ) {
printTable(
$c + 1,
$line['linktg'],
$line['time'],
$line['callsign'],
$line['slot'],
$line['tg'],
$line['duration'],
$line['loss'],
$line['ber']
);
if( ++$c >= MAXENTRIES ) break;
} // end foreach $printLines
} // end function
function qrzRepeater( $rpt ) {
/* $pos = strpos( $rpt, "OE" );
if( $pos !== false) {
$rpt = "<a href=\"https://qrz.com/db/$rpt\" target=\"_blank\">$rpt</a>";
} */
if( preg_match( '/[A-Z]{1,2}\d[A-Z]{1,3}/', $rpt )) {
$rpt = "<a href=\"https://qrz.com/db/$rpt\" target=\"_blank\">$rpt</a>";
}
return $rpt;
}
function printTableYSF( $id=0, $time, $callsign, $dgid, $duration, $repeater, $loss = "---", $ber = "---" ) {
if( $duration >= 60 ) {
$min = str_pad( intval( $duration / 60 ), 2, "0", STR_PAD_LEFT );
$sec = str_pad( $duration % 60, 2, "0", STR_PAD_LEFT );
$duration = "$min:$sec";
} else {
$duration = "00:" . str_pad( $duration, 2, "0", STR_PAD_LEFT );
}
echo " <tr>\n" .
"<td>$id</td>\n" .
"<td>$time</td>\n" .
"<td>" . linkCallsign( $callsign ) ."</td>\n" .
"<td>$dgid</td>\n" .
"<td>$repeater</td>\n" .
"<td>$duration</td>\n" .
"<td>$loss</td>\n" .
"<td>$ber</td>\n" .
"</tr>\n";
}
// function getLastHeard($logpath = BM_LOGPATH, $prefix = BM_PREFIX, $linktg = false, $limit = MAXENTRIES) {
// $logPath = "$logpath/$prefix-*.log";
// $logLines = explode( "\n", `egrep -h "DMR Slot" $logPath` );
function getLastHeardYSF($logpath = MMDVMHOST_LOGPATH, $prefix = MMDVMHOST_PREFIX, $limit = MAXENTRIES) {
$logPath = "$logpath/$prefix-*.log";
$logLines = explode( "\n", `egrep -h "YSF," $logPath` );
$oldline = "";
$time = "";
$loss = "";
$ber = "";
$rssi = "";
$call = "";
$duration = "";
$repeater = "";
$printLines = [];
foreach( $logLines as $line ) {
if( empty( $oldline ) && strpos( $line, "network watchdog" )) {
// $oldine=$line;
continue;
}
if( strpos( $line, "RF end of transmission" )) {
$time = date( "Y-m-d H:i:s", strtotime( substr( $line, 3, 23 )." UTC" ));
$callsign = substr( $line, 69, strpos( $line, "to" ) - 69 );
//$dgid = substr( $line, 83, strpos( $line, ",", 83 ) - 83 );
$dgid = substr( $line, strpos( $line, "to " ) + 3, strpos( $line, " ", strpos( $line, "to " ) + 3) - strpos( $line, "to " ) + 3 );
//$repeater = substr( $oldline, strpos( $oldline, "at " ) + 3, strpos( $oldline, " ", strpos( $oldline, "at " ) + 3) - strpos( $oldline, "at " ) + 3 );
$duration = round( trim( substr( $line, 92, strpos( $line, "seconds,", 92 ) - 92 ), " ," ));
$rssi_values = explode( "/", substr( $line, 113, strpos( $line, "dBm", 113 ) - 113 ));
$rssi = rssiCalc( round( array_sum( $rssi_values ) / count( $rssi_values )));
$loss = "---";
$ber = substr( $line, 111, strpos( $line, ",", 111 ) - 111 );
if( empty( $ber )) $ber = "---";
$repeater = $rssi; // use this testwise, debug
} elseif( strpos( $line, "network data" )) {
if( strpos( $oldline, "network data" )) {
$oldline = $line;
continue;
} else {
$time = date( "Y-m-d H:i:s", strtotime( substr( $line, 3, 23 )." UTC" ));
$old_time = strtotime( $time );
$oldline=$line;
continue;
}
} elseif( strpos( $line, "network watchdog" )) {
$time = date( "Y-m-d H:i:s", strtotime( substr( $oldline, 3, 23 )." UTC" ));
$callsign = trim( substr( $oldline, 59, strpos( $oldline, "to" ) - 59 ));
if( strpos( $oldline, "DG-ID" )) {
$dgid = substr( $oldline, 79, strpos( $oldline, "at " ) - 79 );
} else {
$dgid = substr( $oldline, 73, strpos( $oldline, "at " ) - 73 );
}
//$dgid = substr( $oldline, strpos( $oldline, "to " ) + 3, strpos( $oldline, " ", strpos( $oldline, "to " ) + 3) - strpos( $oldline, "to " ) + 3 );
$new_time = strtotime( date( "Y-m-d H:i:s", strtotime( substr( $oldline, 3, 23 )." UTC" )));
$duration = intval(( $new_time - $old_time ));
$rpt = substr( $oldline, strpos( $oldline, "at " ) + 3, strpos( $oldline, " ", strpos( $oldline, "at " ) + 3) - strpos( $oldline, "at " ) + 3 );
$repeater = qrzRepeater( trim( $rpt ));
$loss = substr( $line, 75, strpos( $line, "%", 75 ) - 74 );
if( $loss == "0%" ) {
$loss = "-x-";
}
$ber = substr( $line, 96, strpos( $line, "%", 96 ) - 95 );
if( $ber == "0.0%" ) $ber = "-x-";
} else {
continue;
}
$tmp = [];
$tmp['time'] = $time;
$tmp['callsign'] = $callsign;
$tmp['dgid'] = $dgid;
$tmp['duration'] = $duration;
$tmp['repeater'] = $repeater;
$tmp['loss'] = $loss;
$tmp['ber'] = $ber;
array_unshift( $printLines, $tmp );
unset( $tmp );
// Lastly we set $oldline as the actual line
$oldline = $line;
}
$c = 0;
foreach( $printLines as $key=>$line ) {
printTableYSF(
$c + 1,
$line['time'],
$line['callsign'],
$line['dgid'],
$line['duration'],
$line['repeater'],
$line['loss'],
$line['ber']
);
if( ++$c >= MAXENTRIES ) break;
} // end foreach $printLines
} // end function
function printLogs($logpath, $limit = MAXLOGENTRIES) {
$logPath = "$logpath/*-".gmdate("Y-m-d").".log";
$logLines = explode("\n", `tail -n $limit $logPath`);
echo "\n<!-- start logfile output -->\n<h2>DEBUG LOGFILES OUTPUT</h2>\n";
echo "<div style=\"text-align:left;font-size:0.8em;\"><code><pre>\n";
foreach( $logLines as $line ) {
if ( substr( $line, 0, 4) == "==> " ) {
echo "<strong style=\"font-size:1.3em;\">$line</strong>\n";
} else {
echo "$line\n";
}
}
echo "\n</pre></code></div>\n<!-- end logfile output -->\n\n";
return 0;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

@ -0,0 +1,118 @@
<?php
/*
* index.php
* Dashboard for my personal hotspot dashboard
* Dominic Reich, OE7DRT, oe7drt@oevsv.at
*/
$time_start = microtime(true);
include("conf.php");
include("func.php");
$mem = ImportDB();
?><!DOCTYPE html>
<html>
<head>
<title><?php echo CALLSIGN ?> Dashboard</title>
<meta name=viewport content="width=device-width,initial-scale=1">
<meta name=generator content="Sublime Text 3 / Vim">
<meta name="author" content="Dominic Reich">
<link rel="stylesheet" type="text/css" media="screen" href="dash.min.css" />
<meta http-equiv="refresh" content="60">
</head>
<body>
<div id="container">
<div id="header">
<a href="<?php echo $_SERVER['REQUEST_URI'] ?>"><h1><?php echo CALLSIGN ?> Hotspot Dashboard</h1></a>
</div>
<div id="content">
<table id="toptable" align="center" width="100%" cellpadding="2px" border="0">
<tr>
<th>Hostname</th>
<th>Model</th>
<th>CPU Freq.</th>
<th>Load</th>
<th>Uptime</th>
<th>Temp.</th>
</tr>
<tr>
<td><?php echo trim(`hostname`); ?> (<?php echo trim(`hostname -I | cut -d' ' -f1`); ?>)</td>
<td><?php echo trim( `cat /sys/firmware/devicetree/base/model | sed 's/Raspberry\ Pi/RPi/'` ); ?> (<?php echo trim( `uname -sr` ); ?>)</td>
<td><?php echo round((int)`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq` / 1000) . " MHz"; ?></td>
<td><?php echo str_replace(","," /",implode(", ", explode(" ", `cat /proc/loadavg`, -2))); ?></td>
<td><?php echo getUptime(); ?></td>
<td><?php echo round((int)`cat /sys/class/thermal/thermal_zone0/temp` / 1000) . "°C"; ?></td>
</tr>
</table>
<div id="bmtable">
<h2>YSF</h2>
<table width="100%" cellpadding="2px" border="0">
<tr>
<th>#</th>
<th>Time (<?php echo date("T"); ?>)</th>
<th>Call</th>
<th>DG-ID</th>
<th>Source</th>
<th>Dur</th>
<th>Loss</th>
<th>BER</th>
</tr>
<?php getLastHeardYSF(MMDVMHOST_LOGPATH, MMDVMHOST_PREFIX) ?>
</table>
<div class="box">
<table width="100%" cellpadding="2px" border="0">
<tr>
<th>Hotspot ID</th>
<th>Startup Reflector</th>
<th><?php echo countDGIDs() ?> DG-IDs booked</th>
</tr>
<tr>
<?php getYSFInfo(); ?>
</tr>
</table>
</div>
</div>
<div id="ipsctable">
<h2>IPSC</h2>
<table width="100%" cellpadding="2px" border="0">
<tr>
<th>#</th>
<th>Time (<?php echo date("T"); ?>)</th>
<th>Call</th>
<th>Slot</th>
<th>TG</th>
<th>Dur</th>
<th>Loss</th>
<th>BER</th>
</tr>
<?php getLastHeard(IPSC_LOGPATH, IPSC_PREFIX) ?>
</table>
<div class="box">
<table width="100%" cellpadding="2px" border="0">
<tr>
<th>Hotspot&nbsp;ID</th>
<th>Server</th>
<!-- <th>Port</th> -->
<th>DMR Options</th>
</tr>
<tr>
<?php getIPSCInfo(); ?>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
I worked <?php $time_end = microtime(true); echo (round($time_end - $time_start, 3)*1000)."ms"; ?> on this page request &mdash; I hope this makes you happy.
</div>
</div>
</body>
</html>
<!-- <?php //$time_end = microtime(true); echo (round($time_end - $time_start, 3)*1000)."ms"; ?>-.- -->

@ -0,0 +1,57 @@
#!/bin/bash
# Get an actual dmrid.dat file from radioid.net
# This file got some more logic to also handle backups,
# the code for that was taken from YSFHostsupdate.sh from
# YSFClients:
# https://github.com/g4klx/YSFClients/blob/master/DGIdGateway/YSFHostsupdate.sh
#
###############################################################################
###############################################################################
#
# YSFHostsupdate.sh
#
# Copyright (C) 2016 by Tony Corbett G0WFV
# Adapted to YSFHosts by Paul Nannery KC2VRJ on 6/28/2016 with all crdeit
# to G0WFV for the orignal script.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
###############################################################################
DMRIDFILE=/home/pi/dmrid.dat
BACKUPS=1
if [ ${BACKUPS} -ne 0 ]
then
cp ${DMRIDFILE} ${DMRIDFILE}.$(date +%Y%m%d)
fi
COUNT=$(ls ${DMRIDFILE}.* | wc -l)
TODELETE=$(expr ${COUNT} - ${BACKUPS})
if [ ${COUNT} -gt ${BACKUPS} ]
then
for f in $(ls -tr ${DMRIDFILE}.* | head -${TODELETE})
do
rm -f $f
done
fi
curl https://www.radioid.net/static/dmrid.dat > ${DMRIDFILE}
exit 0
Loading…
Cancel
Save