Dashboard order

pull/14/head
Tom Early 6 years ago
parent 9a4e6451c4
commit c49692f129

@ -1,7 +1,7 @@
##### DASHBOARD.README ##### ##### DASHBOARD.README #####
A web-based dashboard can be enabled. The dashboard has several sections 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 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 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. 10 seconds. If you do, it will become difficult to use the Send URCall button.

@ -345,7 +345,8 @@ bool CQnetGateway::ReadConfig(char *cfgFile)
// dashboard // dashboard
path.assign("dash_"); 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); cfg.GetValue(path+"sql_filename", estr, DASH_SQL_NAME, 1, 32);
return false; 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); 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 sfx((const char *)g2buf.hdr.sfx, 4);
std::string urcall((const char *)g2buf.hdr.urcall, 8); std::string urcall((const char *)g2buf.hdr.urcall, 8);
rtrim(mycall); rtrim(mycall);
@ -2268,7 +2269,7 @@ bool CQnetGateway::Init(char *cfgfile)
} }
// open database // open database
if (DASH_SHOW_LH) { if (showLastHeard) {
std::string dbname(CFG_DIR); std::string dbname(CFG_DIR);
dbname.append("/"); dbname.append("/");
dbname.append(DASH_SQL_NAME); dbname.append(DASH_SQL_NAME);

@ -103,11 +103,10 @@ private:
std::string gate2link, link2gate, gate2modem[3], modem2gate; 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 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; 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;

@ -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_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_refresh_d=20 # seconds for the webpage to reload
dash_lastheard_count_d=20 # maximum number of last heard entries to display 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_order_d='LH,MO,SY,IP,PS,UR' # Show sections in this order
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

@ -123,7 +123,12 @@ ParseKVFile($cfgdir.'/defaults', $defaults);
<h2>QnetGateway <?php echo GetCFGValue('ircddb_login'); ?> Dashboard</h2> <h2>QnetGateway <?php echo GetCFGValue('ircddb_login'); ?> Dashboard</h2>
<?php <?php
if ('true' == GetCFGValue('dash_show_ps') && `ps -aux | grep -e qn -e MMDVMHost | wc -l` > 2) { $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:<br><code>', "\n"; echo 'Processes:<br><code>', "\n";
echo str_replace(' ', '&nbsp;', 'USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND<br>'), "\n"; echo str_replace(' ', '&nbsp;', 'USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND<br>'), "\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`); $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`);
@ -131,9 +136,9 @@ if ('true' == GetCFGValue('dash_show_ps') && `ps -aux | grep -e qn -e MMDVMHost
echo str_replace(' ', '&nbsp;', $line), "<br>\n"; echo str_replace(' ', '&nbsp;', $line), "<br>\n";
} }
echo '</code>', "\n"; echo '</code>', "\n";
} }
break;
if ('true' == GetCFGValue('dash_show_sy')) { case 'SY':
echo 'System Info:<br>', "\n"; echo 'System Info:<br>', "\n";
$hn = trim(`uname -n`); $hn = trim(`uname -n`);
$kn = trim(`uname -rmo`); $kn = trim(`uname -rmo`);
@ -152,9 +157,8 @@ if ('true' == GetCFGValue('dash_show_sy')) {
echo '<table cellpadding="1" border="1" style="font-family: monospace">', "\n"; echo '<table cellpadding="1" border="1" style="font-family: monospace">', "\n";
echo '<tr><td style="text-align:center">Hostname</td><td style="text-align:center">Kernel</td><td style="text-align:center">OS</td><td style="text-align:center">CPU</td></tr>', "\n"; echo '<tr><td style="text-align:center">Hostname</td><td style="text-align:center">Kernel</td><td style="text-align:center">OS</td><td style="text-align:center">CPU</td></tr>', "\n";
echo '<tr><td style="text-align:center">', $hn, '</td><td style="text-align:center">', $kn, '</td><td style="text-align:center">', $os, '</td><td style="text-align:center">', $cu, '</td></tr></table><br>', "\n"; echo '<tr><td style="text-align:center">', $hn, '</td><td style="text-align:center">', $kn, '</td><td style="text-align:center">', $os, '</td><td style="text-align:center">', $cu, '</td></tr></table><br>', "\n";
} break;
case 'LH':
if ('true' == GetCFGValue('dash_show_lh')) {
echo 'Last Heard:<br><code>', "\n"; echo 'Last Heard:<br><code>', "\n";
$rstr = 'MyCall/Sfx Source Last Time<br>'; $rstr = 'MyCall/Sfx Source Last Time<br>';
echo str_replace(' ', '&nbsp;', $rstr), "\n"; echo str_replace(' ', '&nbsp;', $rstr), "\n";
@ -174,20 +178,18 @@ if ('true' == GetCFGValue('dash_show_lh')) {
} }
$db->Close(); $db->Close();
echo '</code><br>', "\n"; echo '</code><br>', "\n";
} break;
case 'IP':
if ('true' == GetCFGValue('dash_show_ip')) {
echo 'IP Addresses:<br>', "\n"; echo 'IP Addresses:<br>', "\n";
echo '<table cellpadding="1" border="1" style="font-family: monospace">', "\n"; echo '<table cellpadding="1" border="1" style="font-family: monospace">', "\n";
echo '<tr><td style="text-align:center">Internal</td><td style="text-align:center">IPV4</td><td style="text-align:center">IPV6</td></tr>', "\n"; echo '<tr><td style="text-align:center">Internal</td><td style="text-align:center">IPV4</td><td style="text-align:center">IPV6</td></tr>', "\n";
echo '<tr><td>', GetIP('internal'), '</td><td>', GetIP('ipv4'), '</td><td>', GetIP('ipv6'), '</td></tr>', "\n"; echo '<tr><td>', GetIP('internal'), '</td><td>', GetIP('ipv4'), '</td><td>', GetIP('ipv6'), '</td></tr>', "\n";
echo '</table><br>', "\n"; echo '</table><br>', "\n";
} break;
case 'MO':
if ('true' == GetCFGValue('dash_show_mo')) {
echo 'Modules:<br>', "\n"; echo 'Modules:<br>', "\n";
echo "<table cellpadding='1' border='1' style='font-family: monospace'>\n"; echo "<table cellpadding='1' border='1' style='font-family: monospace'>\n";
echo '<tr><td style="text-align:center">Module</td><td style="text-align:center">Modem</td><td style="text-align:center">Frequency</td><td style="text-align:center">Repeater</td><td style="text-align:center">Repeater IP</td></tr>', "\n"; echo '<tr><td style="text-align:center">Module</td><td style="text-align:center">Modem</td><td style="text-align:center">Frequency</td><td style="text-align:center">Link</td><td style="text-align:center">Link IP</td></tr>', "\n";
foreach (array('a', 'b', 'c') as $mod) { foreach (array('a', 'b', 'c') as $mod) {
$module = 'module_'.$mod; $module = 'module_'.$mod;
if (array_key_exists($module, $cfg)) { if (array_key_exists($module, $cfg)) {
@ -206,9 +208,8 @@ if ('true' == GetCFGValue('dash_show_mo')) {
} }
} }
echo '</table><br>', "\n"; echo '</table><br>', "\n";
} break;
case 'UR':
if ('true' == GetCFGValue('dash_show_ur')) {
echo 'Send URCall:<br>', "\n"; echo 'Send URCall:<br>', "\n";
echo '<form method="post">', "\n"; echo '<form method="post">', "\n";
if (count($configured) > 1) { if (count($configured) > 1) {
@ -238,6 +239,11 @@ if ('true' == GetCFGValue('dash_show_ur')) {
echo $command, "<br>\n"; echo $command, "<br>\n";
$unused = `$command`; $unused = `$command`;
} }
break;
default:
echo 'Section "', $section, '" was not found!<br>', "\n";
break;
}
} }
?> ?>
<br> <br>

@ -146,33 +146,29 @@ DashboardMenu () {
fi fi
echo -n "r : Refresh time (sec) for page = "; EvaluateVar dash_refresh{,_d} 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 "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 "o : Show Section Order = "; EvaluateVar dash_show_order{,_d}
echo -n "y : Show the System = "; EvaluateVar dash_show_sy{,_d} echo
echo -n "l : Show the Last Heard = "; EvaluateVar dash_show_lh{,_d} echo " The 'Show Section' is a comma separated value, e.g. 'lh,mo,sy,ip,ps,ur'"
echo -n "i : Show the IP Addresses = "; EvaluateVar dash_show_ip{,_d} echo " The following sections can be shown in any order. It's okay to leave out sections."
echo -n "m : Show the Modules(s) = "; EvaluateVar dash_show_mo{,_d} echo " Don't use spaces, just use commas. Lowercase will be set to uppercase."
echo -n "s : Show the Send URCall = "; EvaluateVar dash_show_ur{,_d} 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 EndMenu
if [[ "$key" == n* ]]; then dash_sql_filename="$value" if [[ "$key" == n* ]]; then dash_sql_filename="$value"
elif [[ "$key" == r* ]]; then dash_refresh="$value" elif [[ "$key" == r* ]]; then dash_refresh="$value"
elif [[ "$key" == c* ]]; then dash_lastheard_count="$value" elif [[ "$key" == c* ]]; then dash_lastheard_count="$value"
elif [[ "$key" == p* ]]; then SetBooleanValue dash_show_ps "$value" elif [[ "$key" == o* ]]; then dash_show_order="${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" == u* ]]; then elif [[ "$key" == u* ]]; then
if [[ "$value" == n* ]]; then unset dash_sql_filename if [[ "$value" == n* ]]; then unset dash_sql_filename
elif [[ "$value" == r* ]]; then unset dash_refresh elif [[ "$value" == r* ]]; then unset dash_refresh
elif [[ "$value" == c* ]]; then unset dash_lastheard_count elif [[ "$value" == c* ]]; then unset dash_lastheard_count
elif [[ "$value" == p* ]]; then unset dash_show_ps elif [[ "$value" == o* ]]; then unset dash_show_order
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
fi fi
fi fi
done done
@ -700,12 +696,7 @@ WriteCFGFile () {
[ -z "${dash_sql_filename+x}" ] || echo "dash_sql_filename='${dash_sql_filename}'" >> $outFile [ -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_refresh+x}" ] || echo "dash_refresh=${dash_refresh}" >> $outFile
[ -z "${dash_lastheard_count+x}" ] || echo "dash_lastheard_count=${dash_lastheard_count}" >> $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_order+x}" ] || echo "dash_show_order='${dash_show_order}'" >> $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
clear clear
cat $outFile cat $outFile
echo echo

Loading…
Cancel
Save

Powered by TurnKey Linux.