diff --git a/DASHBOARD.README b/DASHBOARD.README
index 075b10e..bc9be75 100644
--- a/DASHBOARD.README
+++ b/DASHBOARD.README
@@ -1,7 +1,7 @@
##### DASHBOARD.README #####
A web-based dashboard can be enabled. The dashboard has several sections
-that you can disable if you want. You can also control the refresh rate and
+that you can display in any order. You can also control the refresh rate and
how many rows you want in the Last Heard section. You can configure these
features with the ./qnconfig menu. Don't set the refresh time faster than about
10 seconds. If you do, it will become difficult to use the Send URCall button.
diff --git a/QnetGateway.cpp b/QnetGateway.cpp
index 1af1bef..52363f3 100644
--- a/QnetGateway.cpp
+++ b/QnetGateway.cpp
@@ -345,7 +345,8 @@ bool CQnetGateway::ReadConfig(char *cfgFile)
// dashboard
path.assign("dash_");
- cfg.GetValue(path+"show_lh", estr, DASH_SHOW_LH);
+ cfg.GetValue(path+"show_order", estr, DASH_SHOW_ORDER, 2, 17);
+ showLastHeard = (std::string::npos == DASH_SHOW_ORDER.find("LH"));
cfg.GetValue(path+"sql_filename", estr, DASH_SQL_NAME, 1, 32);
return false;
@@ -993,7 +994,7 @@ void CQnetGateway::ProcessG2(const ssize_t g2buflen, const SDSVT &g2buf, const i
}
std::string mycall((const char *)g2buf.hdr.mycall, 8);
- if (DASH_SHOW_LH && memcmp(g2buf.hdr.sfx, "RPTR", 4) && std::regex_match(mycall.c_str(), preg)) {
+ if (showLastHeard && memcmp(g2buf.hdr.sfx, "RPTR", 4) && std::regex_match(mycall.c_str(), preg)) {
std::string sfx((const char *)g2buf.hdr.sfx, 4);
std::string urcall((const char *)g2buf.hdr.urcall, 8);
rtrim(mycall);
@@ -2268,7 +2269,7 @@ bool CQnetGateway::Init(char *cfgfile)
}
// open database
- if (DASH_SHOW_LH) {
+ if (showLastHeard) {
std::string dbname(CFG_DIR);
dbname.append("/");
dbname.append(DASH_SQL_NAME);
diff --git a/QnetGateway.h b/QnetGateway.h
index ed9fe03..fdb3693 100644
--- a/QnetGateway.h
+++ b/QnetGateway.h
@@ -103,11 +103,10 @@ private:
std::string gate2link, link2gate, gate2modem[3], modem2gate;
- std::string OWNER, owner, FILE_STATUS, FILE_DTMF, FILE_ECHOTEST, IRCDDB_PASSWORD[2], FILE_QNVOICE_FILE, DASH_SQL_NAME;
+ std::string OWNER, owner, FILE_STATUS, FILE_DTMF, FILE_ECHOTEST, IRCDDB_PASSWORD[2], FILE_QNVOICE_FILE, DASH_SQL_NAME, DASH_SHOW_ORDER;
- bool GATEWAY_SEND_QRGS_MAP, GATEWAY_HEADER_REGEN, APRS_ENABLE, playNotInCache;
+ bool GATEWAY_SEND_QRGS_MAP, GATEWAY_HEADER_REGEN, APRS_ENABLE, playNotInCache, showLastHeard;
bool LOG_DEBUG, LOG_IRC, LOG_DTMF, LOG_QSO;
- bool DASH_SHOW_LH;
int DASH_REFRESH, TIMING_PLAY_WAIT, TIMING_PLAY_DELAY, TIMING_TIMEOUT_ECHO, TIMING_TIMEOUT_VOICEMAIL, TIMING_TIMEOUT_REMOTE_G2, TIMING_TIMEOUT_LOCAL_RPTR, dtmf_digit;
diff --git a/defaults b/defaults
index 7c198ba..344fbca 100644
--- a/defaults
+++ b/defaults
@@ -219,9 +219,4 @@ timing_play_delay_d=19 # milliseconds between frames playback, if echo so
dash_sql_filename_d='qn.db' # name for the sqlite database in the $CFGDIR directory
dash_refresh_d=20 # seconds for the webpage to reload
dash_lastheard_count_d=20 # maximum number of last heard entries to display
-dash_show_sy_d=true # set to false if for no System Info section
-dash_show_lh_d=true # set to false if for no Last Heard section
-dash_show_ps_d=true # set to false if for no Processes section
-dash_show_ip_d=true # set to false if for no IP Addresses section
-dash_show_mo_d=true # set to false if for no Modules section
-dash_show_ur_d=true # set to false if for Send URCall section
+dash_show_order_d='LH,MO,SY,IP,PS,UR' # Show sections in this order
diff --git a/index.php b/index.php
index 78587c0..2c59cd5 100644
--- a/index.php
+++ b/index.php
@@ -123,120 +123,126 @@ ParseKVFile($cfgdir.'/defaults', $defaults);
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 grep`);
- foreach ($lines as $line) {
- echo str_replace(' ', ' ', $line), "
\n";
- }
- echo '', "\n";
-}
-
-if ('true' == GetCFGValue('dash_show_sy')) {
- echo 'System Info:
', "\n";
- $hn = trim(`uname -n`);
- $kn = trim(`uname -rmo`);
- $oslist = explode(':', `lsb_release -d`);
- $os = trim($oslist[1]);
- $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 '| Hostname | Kernel | OS | CPU |
', "\n";
- echo '| ', $hn, ' | ', $kn, ' | ', $os, ' | ', $cu, ' |
', "\n";
-}
-
-if ('true' == GetCFGValue('dash_show_lh')) {
- echo 'Last Heard:
', "\n";
- $rstr = 'MyCall/Sfx Source Last Time
';
- echo str_replace(' ', ' ', $rstr), "\n";
- $dbname = $cfgdir.'/'.GetCFGValue('dash_sql_filename');
- $db = new SQLite3($dbname, SQLITE3_OPEN_READONLY);
- $ss = 'SELECT mycall,sfx,urcall,strftime("%s","now")-lasttime FROM LHEARD ORDER BY 4 LIMIT '.GetCFGValue('dash_lastheard_count').' ';
- if ($stmnt = $db->prepare($ss)) {
- if ($result = $stmnt->execute()) {
- while ($row = $result->FetchArray(SQLITE3_NUM)) {
- $source = ("CQCQCQ " == $row[2]) ? "Linking" : "Routing";
- $rstr = MyAndSfxToQrz($row[0], $row[1]).' '.$source.' '.SecToString(intval($row[3])).'
';
- echo str_replace('*', ' ', str_replace(' ', ' ', $rstr)), "\n";
+$showorder = GetCFGValue('dash_show_order');
+$showlist = explode(',', trim($showorder));
+foreach($showlist as $section) {
+ switch ($section) {
+ case 'PS':
+ if (`ps -aux | grep -e qn -e MMDVMHost | wc -l` > 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 grep`);
+ foreach ($lines as $line) {
+ echo str_replace(' ', ' ', $line), "
\n";
+ }
+ echo '', "\n";
}
- $result->finalize();
- }
- $stmnt->close();
- }
- $db->Close();
- echo '
', "\n";
-}
-
-if ('true' == GetCFGValue('dash_show_ip')) {
- echo 'IP Addresses:
', "\n";
- echo '', "\n";
- echo '| Internal | IPV4 | IPV6 |
', "\n";
- echo '| ', GetIP('internal'), ' | ', GetIP('ipv4'), ' | ', GetIP('ipv6'), ' |
', "\n";
- echo '
', "\n";
-}
-
-if ('true' == GetCFGValue('dash_show_mo')) {
- echo 'Modules:
', "\n";
- echo "\n";
- echo '| Module | Modem | Frequency | Repeater | Repeater IP |
', "\n";
- foreach (array('a', 'b', 'c') as $mod) {
- $module = 'module_'.$mod;
- if (array_key_exists($module, $cfg)) {
- $configured[] = strtoupper($mod);
- $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'];
- $stat = GetStatus($mod, $cfg);
- if (8==strlen($stat[1]) && 1==strlen($stat[2]))
- $linkstatus = substr($stat[1], 0, 7).$stat[2];
- else
- $linkstatus = 'Unlinked';
- echo '| ',strtoupper($mod),' | ',$cfg[$module],' | ',$freq,' | ',$linkstatus,' | ',$stat[3],' |
',"\n";
- }
- }
- echo '
', "\n";
-}
-
-if ('true' == GetCFGValue('dash_show_ur')) {
- echo 'Send URCall:
', "\n";
- echo '', "\n";
- if (isset($_POST['sendurcall'])) {
- $furcall = $_POST['furcall'];
- if (empty($_POST['fmodule'])) {
- if (1==count($configured)) {
+ break;
+ case 'SY':
+ echo 'System Info:
', "\n";
+ $hn = trim(`uname -n`);
+ $kn = trim(`uname -rmo`);
+ $oslist = explode(':', `lsb_release -d`);
+ $os = trim($oslist[1]);
+ $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 '| Hostname | Kernel | OS | CPU |
', "\n";
+ echo '| ', $hn, ' | ', $kn, ' | ', $os, ' | ', $cu, ' |
', "\n";
+ break;
+ case 'LH':
+ echo 'Last Heard:
', "\n";
+ $rstr = 'MyCall/Sfx Source Last Time
';
+ echo str_replace(' ', ' ', $rstr), "\n";
+ $dbname = $cfgdir.'/'.GetCFGValue('dash_sql_filename');
+ $db = new SQLite3($dbname, SQLITE3_OPEN_READONLY);
+ $ss = 'SELECT mycall,sfx,urcall,strftime("%s","now")-lasttime FROM LHEARD ORDER BY 4 LIMIT '.GetCFGValue('dash_lastheard_count').' ';
+ if ($stmnt = $db->prepare($ss)) {
+ if ($result = $stmnt->execute()) {
+ while ($row = $result->FetchArray(SQLITE3_NUM)) {
+ $source = ("CQCQCQ " == $row[2]) ? "Linking" : "Routing";
+ $rstr = MyAndSfxToQrz($row[0], $row[1]).' '.$source.' '.SecToString(intval($row[3])).'
';
+ echo str_replace('*', ' ', str_replace(' ', ' ', $rstr)), "\n";
+ }
+ $result->finalize();
+ }
+ $stmnt->close();
+ }
+ $db->Close();
+ echo '
', "\n";
+ break;
+ case 'IP':
+ echo 'IP Addresses:
', "\n";
+ echo '', "\n";
+ echo '| Internal | IPV4 | IPV6 |
', "\n";
+ echo '| ', GetIP('internal'), ' | ', GetIP('ipv4'), ' | ', GetIP('ipv6'), ' |
', "\n";
+ echo '
', "\n";
+ break;
+ case 'MO':
+ echo 'Modules:
', "\n";
+ echo "\n";
+ echo '| Module | Modem | Frequency | Link | Link IP |
', "\n";
+ foreach (array('a', 'b', 'c') as $mod) {
+ $module = 'module_'.$mod;
+ if (array_key_exists($module, $cfg)) {
+ $configured[] = strtoupper($mod);
+ $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'];
+ $stat = GetStatus($mod, $cfg);
+ if (8==strlen($stat[1]) && 1==strlen($stat[2]))
+ $linkstatus = substr($stat[1], 0, 7).$stat[2];
+ else
+ $linkstatus = 'Unlinked';
+ echo '| ',strtoupper($mod),' | ',$cfg[$module],' | ',$freq,' | ',$linkstatus,' | ',$stat[3],' |
',"\n";
+ }
+ }
+ echo '
', "\n";
+ break;
+ case 'UR':
+ echo 'Send URCall:
', "\n";
+ echo '', "\n";
+ if (isset($_POST['sendurcall'])) {
+ $furcall = $_POST['furcall'];
+ if (empty($_POST['fmodule'])) {
+ if (1==count($configured)) {
+ $fmodule = $configured[0];
+ }
+ } else {
+ $fmodule = $_POST['fmodule'];
+ }
}
- } else {
- $fmodule = $_POST['fmodule'];
- }
- }
- $furcall = str_replace(' ', '_', trim(preg_replace('/[^0-9a-z_ ]/', '', strtolower($furcall))));
+ $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`;
+ 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;
}
}
?>
diff --git a/qnconfig b/qnconfig
index 234739d..26db763 100755
--- a/qnconfig
+++ b/qnconfig
@@ -146,33 +146,29 @@ DashboardMenu () {
fi
echo -n "r : Refresh time (sec) for page = "; EvaluateVar dash_refresh{,_d}
echo -n "c : Max number of last heard entries = "; EvaluateVar dash_lastheard_count{,_d}
- echo -n "p : Show the Processes = "; EvaluateVar dash_show_ps{,_d}
- echo -n "y : Show the System = "; EvaluateVar dash_show_sy{,_d}
- echo -n "l : Show the Last Heard = "; EvaluateVar dash_show_lh{,_d}
- echo -n "i : Show the IP Addresses = "; EvaluateVar dash_show_ip{,_d}
- echo -n "m : Show the Modules(s) = "; EvaluateVar dash_show_mo{,_d}
- echo -n "s : Show the Send URCall = "; EvaluateVar dash_show_ur{,_d}
+ echo -n "o : Show Section Order = "; EvaluateVar dash_show_order{,_d}
+ echo
+ echo " The 'Show Section' is a comma separated value, e.g. 'lh,mo,sy,ip,ps,ur'"
+ echo " The following sections can be shown in any order. It's okay to leave out sections."
+ echo " Don't use spaces, just use commas. Lowercase will be set to uppercase."
+ echo
+ echo " LH is the Last Heard Section"
+ echo " MO is the Modules Section"
+ echo " SY is the System Section"
+ echo " IP is the IP Address Section"
+ echo " PS is the Processes Section"
+ echo " UR is the Send URCall Section"
EndMenu
if [[ "$key" == n* ]]; then dash_sql_filename="$value"
elif [[ "$key" == r* ]]; then dash_refresh="$value"
elif [[ "$key" == c* ]]; then dash_lastheard_count="$value"
- elif [[ "$key" == p* ]]; then SetBooleanValue dash_show_ps "$value"
- elif [[ "$key" == y* ]]; then SetBooleanValue dash_show_sy "$value"
- elif [[ "$key" == l* ]]; then SetBooleanValue dash_show_lh "$value"
- elif [[ "$key" == i* ]]; then SetBooleanValue dash_show_ip "$value"
- elif [[ "$key" == m* ]]; then SetBooleanValue dash_show_mo "$value"
- elif [[ "$key" == s* ]]; then SetBooleanValue dash_show_ur "$value"
+ elif [[ "$key" == o* ]]; then dash_show_order="${value^^}"
elif [[ "$key" == u* ]]; then
if [[ "$value" == n* ]]; then unset dash_sql_filename
elif [[ "$value" == r* ]]; then unset dash_refresh
elif [[ "$value" == c* ]]; then unset dash_lastheard_count
- elif [[ "$value" == p* ]]; then unset dash_show_ps
- elif [[ "$value" == y* ]]; then unset dash_show_sy
- elif [[ "$value" == l* ]]; then unset dash_show_lh
- elif [[ "$value" == i* ]]; then unset dash_show_ip
- elif [[ "$value" == m* ]]; then unset dash_show_mo
- elif [[ "$value" == s* ]]; then unset dash_show_ur
+ elif [[ "$value" == o* ]]; then unset dash_show_order
fi
fi
done
@@ -700,12 +696,7 @@ WriteCFGFile () {
[ -z "${dash_sql_filename+x}" ] || echo "dash_sql_filename='${dash_sql_filename}'" >> $outFile
[ -z "${dash_refresh+x}" ] || echo "dash_refresh=${dash_refresh}" >> $outFile
[ -z "${dash_lastheard_count+x}" ] || echo "dash_lastheard_count=${dash_lastheard_count}" >> $outFile
- [ -z "${dash_show_ip+x}" ] || echo "dash_show_ip=${dash_show_ip}" >> $outFile
- [ -z "${dash_show_lh+x}" ] || echo "dash_show_lh=${dash_show_lh}" >> $outFile
- [ -z "${dash_show_ps+x}" ] || echo "dash_show_ps=${dash_show_ps}" >> $outFile
- [ -z "${dash_show_sy+x}" ] || echo "dash_show_sy=${dash_show_sy}" >> $outFile
- [ -z "${dash_show_mo+x}" ] || echo "dash_show_mo=${dash_show_mo}" >> $outFile
- [ -z "${dash_show_ur+x}" ] || echo "dash_show_ur=${dash_show_ur}" >> $outFile
+ [ -z "${dash_show_order+x}" ] || echo "dash_show_order='${dash_show_order}'" >> $outFile
clear
cat $outFile
echo