= 86400)
return sprintf("%0.2f days", $sec/86400);
$hrs = intdiv($sec, 3600);
$sec %= 3600;
$min = intdiv($sec, 60);
$sec %= 60;
if ($hrs) return sprintf("%2d hr %2d min", $hrs, $min);
if ($min) return sprintf("%2d min %2d sec", $min, $sec);
return sprintf("%2d sec", $sec);
}
function MyAndSfxToQrz(string $my, string $sfx)
{
$my = trim($my);
$sfx = trim($sfx);
if (0 == strlen($my)) {
$my = 'Empty MYCall ';
} else {
if (strpos($my, ' '))
$link = strstr($my, ' ', true);
else
$link = $my;
if (strlen($sfx))
$my .= '/'.$sfx;
$len = strlen($my);
$my = ''.$my.'';
while ($len < 13) {
$my .= ' ';
$len += 1;
}
}
return $my;
}
//example URL: https://www.google.com/maps?q=+52.37745,+001.99960
function Maidenhead(string $maid, float $lat, float $lon)
{
$str = trim($maid);
if (6 > strlen($str))
return $maid;
if ($lat >= 0.0)
$slat = '+'.$lat;
else
$slat = $lat;
if ($lon >= 0.0)
$slon = '+'.$lon;
else
$slon = $lon;
$str = ''.$maid.'';
return $str;
}
ParseKVFile($cfgdir.'/qn.cfg', $cfg);
ParseKVFile($cfgdir.'/defaults', $defaults);
?>
QnetGateway Dashboard
QnetGateway Dashboard
2) {
echo 'Processes:
', "\n";
echo str_replace(' ', ' ', 'USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
'), "\n";
$lines = explode("\n", `ps -aux | grep -e qngateway -e qnlink -e qndtmf -e qndvap -e qnitap -e qnrelay -e qndvrptr -e qnmodem -e MMDVMHost | grep -v -e grep -e journal`);
foreach ($lines as $line) {
echo str_replace(' ', ' ', $line), "
\n";
}
echo '', "\n";
}
break;
case 'SY':
echo 'System Info:
', "\n";
$hn = trim(`uname -n`);
$kn = trim(`uname -rmo`);
$osinfo = file('/etc/os-release', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($osinfo as $line) {
list( $key, $value ) = explode('=', $line);
if ($key == 'PRETTY_NAME') {
$os = trim($value, '"');
break;
}
}
$cu = trim(`cat /proc/cpuinfo | grep Model`);
if (0 == strlen($cu))
$cu = trim(`cat /proc/cpuinfo | grep "model name"`);
$culist = explode("\n", $cu);
$mnlist = explode(':', $culist[0]);
$cu = trim($mnlist[1]);
if (count($culist) > 1)
$cu .= ' ' . count($culist) . ' Threads';
if (file_exists('/opt/vc/bin/vcgencmd'))
$cu .= ' ' . str_replace("'", '°', trim(`/opt/vc/bin/vcgencmd measure_temp`));
echo '', "\n";
echo '| CPU | Kernel | OS | Hostname |
', "\n";
echo '| ', $cu, ' | ', $kn, ' | ', $os, ' | ', $hn, ' |
', "\n";
break;
case 'LH':
echo 'Last Heard:
', "\n";
$rstr = 'MyCall/Sfx Message Mod Via Maidenhead Time
';
echo str_replace(' ', ' ', $rstr), "\n";
$dbname = $cfgdir.'/qn.db';
$db = new SQLite3($dbname, SQLITE3_OPEN_READONLY);
// 0 1 2 3 4 5 6 7 8
$ss = 'SELECT callsign,sfx,message,module,reflector,maidenhead,latitude,longitude,strftime("%s","now")-lasttime FROM LHEARD ORDER BY 9 LIMIT '.GetCFGValue('dash_lastheard_count').' ';
if ($stmnt = $db->prepare($ss)) {
if ($result = $stmnt->execute()) {
while ($row = $result->FetchArray(SQLITE3_NUM)) {
$rstr = MyAndSfxToQrz($row[0], $row[1]).' '.$row[2].' '.$row[3].' '.$row[4].' '.Maidenhead($row[5], $row[6], $row[7]).' '.SecToString(intval($row[8])).'
';
echo str_replace('*', ' ', str_replace(' ', ' ', $rstr)), "\n";
}
$result->finalize();
}
$stmnt->close();
}
$db->Close();
echo '
', "\n";
break;
case 'IP':
$hasv6 = stristr(GetCFGValue('ircddb0_host'), 'v6');
if (! $hasv6) $hasv6 = stristr(GetCFGValue('ircddb1_host'), 'v6');
echo 'IP Addresses:
', "\n";
echo '', "\n";
echo '| Internal | IPV4 | ';
if ($hasv6) echo 'IPV6 |
';
echo "\n";
echo '| ', GetIP('internal'), ' | ', GetIP('ipv4'), ' | ';
if ($hasv6) echo '', GetIP('ipv6'), ' |
';
echo "\n", '
', "\n";
break;
case 'MO':
echo 'Modules:
', "\n";
$dbname = $cfgdir.'/qn.db';
$db = new SQLite3($dbname, SQLITE3_OPEN_READONLY);
echo "\n";
echo '| Module | Modem | Frequency | Link | Linked Time | Link IP |
', "\n";
foreach (array('a', 'b', 'c') as $mod) {
$linkstatus = 'Unlinked';
$address = '';
$ctime = '';
$module = 'module_'.$mod;
if (array_key_exists($module, $cfg)) {
$freq = 0.0;
if (array_key_exists($module.'_tx_frequency', $cfg))
$freq = $cfg[$module.'_tx_frequency'];
else if (array_key_exists($module.'_frequency', $cfg))
$freq = $cfg[$module.'_frequency'];
$ss = 'SELECT ip_address,to_callsign,to_mod,strftime("%s","now")-linked_time FROM LINKSTATUS WHERE from_mod=' . "'" . strtoupper($mod) . "';";
if ($stmnt = $db->prepare($ss)) {
if ($result = $stmnt->execute()) {
if ($row = $result->FetchArray(SQLITE3_NUM)) {
$linkstatus = str_pad(trim($row[1]), 7).$row[2];
$address = $row[0];
$ctime = SecToString(intval($row[3]));
}
$result->finalize();
}
$stmnt->close();
}
echo '| ', strtoupper($mod), ' | ',$cfg[$module], ' | ', $freq, ' | ', $linkstatus, ' | ', $ctime, ' | ', $address, ' |
', "\n";
}
}
echo '
', "\n";
$db->close();
break;
case 'UR':
echo 'Send URCall:
', "\n";
echo '', "\n";
if (isset($_POST['sendurcall'])) {
$furcall = $_POST['furcall'];
if (empty($_POST['fmodule'])) {
if (1==count($mods)) {
$fmodule = $mods[0];
}
} else {
$fmodule = $_POST['fmodule'];
}
}
$furcall = str_replace(' ', '_', trim(preg_replace('/[^0-9a-z_ ]/', '', strtolower($furcall))));
if (strlen($furcall)>0 && strlen($fmodule)>0) {
$command = 'qnremote '.strtolower($fmodule).' '.strtolower($cfg['ircddb_login']).' '.$furcall;
echo $command, "
\n";
$unused = `$command`;
}
break;
default:
echo 'Section "', $section, '" was not found!
', "\n";
break;
}
}
?>
QnetGateway Dashboard Version 10208 Copyright © by Thomas A. Early, N7TAE.