From 2cb760dae2fa2214240bb0083b060966be548604 Mon Sep 17 00:00:00 2001 From: jim-p Date: Tue, 16 Jul 2013 16:09:16 -0400 Subject: Some more tweaks to state and mbuf update/output on dashboard widget. --- usr/local/www/includes/functions.inc.php | 11 +++++++---- usr/local/www/javascript/index/ajax.js | 8 +++++++- usr/local/www/widgets/widgets/system_information.widget.php | 7 +++---- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/usr/local/www/includes/functions.inc.php b/usr/local/www/includes/functions.inc.php index 359887c..2d3295a 100644 --- a/usr/local/www/includes/functions.inc.php +++ b/usr/local/www/includes/functions.inc.php @@ -22,6 +22,7 @@ function get_stats() { $stats['cpufreq'] = get_cpufreq(); $stats['load_average'] = get_load_average(); $stats['mbuf'] = get_mbuf(); + $stats['mbufpercent'] = get_mbuf(true); $stats['statepercent'] = get_pfstate(true); $stats = join("|", $stats); return $stats; @@ -151,7 +152,7 @@ function get_pfstate($percent=false) { $curentries = $matches[1]; } if ($percent) - return ($curentries / $maxstates) * 100; + return round(($curentries / $maxstates) * 100, 0); else return $curentries . "/" . $maxstates; } @@ -167,11 +168,13 @@ function get_hwtype() { return; } -function get_mbuf() { +function get_mbuf($percent=false) { $mbufs_output=trim(`/usr/bin/netstat -mb | /usr/bin/grep "mbuf clusters in use" | /usr/bin/awk '{ print $1 }'`); list( $mbufs_current, $mbufs_cache, $mbufs_total, $mbufs_max ) = explode( "/", $mbufs_output); - $mbufusage = round(($mbufs_total / $mbufs_max) * 100); - return $mbufusage; + if ($percent) + return round(($mbufs_total / $mbufs_max) * 100, 0); + else + return "{$mbufs_total}/{$mbufs_max}"; } function get_temp() { diff --git a/usr/local/www/javascript/index/ajax.js b/usr/local/www/javascript/index/ajax.js index 3bfd67b..fa33914 100644 --- a/usr/local/www/javascript/index/ajax.js +++ b/usr/local/www/javascript/index/ajax.js @@ -44,7 +44,8 @@ function stats(x) { updateCpuFreq(values[9]); updateLoadAverage(values[10]); updateMbuf(values[11]); - updateStateMeter(values[12]); + updateMbufMeter(values[12]); + updateStateMeter(values[13]); } function updateMemory(x) { @@ -57,6 +58,11 @@ function updateMemory(x) { } function updateMbuf(x) { + if(jQuery('#mbuf')) + jQuery("#mbuf").html(x); +} + +function updateMbufMeter(x) { if(jQuery('#mbufusagemeter')) jQuery("#mbufusagemeter").html(x + '%'); if(jQuery('#mbufwidtha')) diff --git a/usr/local/www/widgets/widgets/system_information.widget.php b/usr/local/www/widgets/widgets/system_information.widget.php index e8ff29e..d19627d 100644 --- a/usr/local/www/widgets/widgets/system_information.widget.php +++ b/usr/local/www/widgets/widgets/system_information.widget.php @@ -199,12 +199,11 @@ $curcfg = $config['system']['firmware']; left barred bargray barright bar -
(/) +
() -- cgit v1.1