From bdc3d5ca64d2c80c18fa1eb6f071226ca78ed8c1 Mon Sep 17 00:00:00 2001 From: jim-p Date: Tue, 16 Jul 2013 15:38:24 -0400 Subject: Add a meter for states, too --- usr/local/www/includes/functions.inc.php | 8 ++++++-- usr/local/www/javascript/index/ajax.js | 10 ++++++++++ usr/local/www/widgets/widgets/system_information.widget.php | 6 +++++- 3 files changed, 21 insertions(+), 3 deletions(-) (limited to 'usr/local/www') diff --git a/usr/local/www/includes/functions.inc.php b/usr/local/www/includes/functions.inc.php index 3e00d13..359887c 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['statepercent'] = get_pfstate(true); $stats = join("|", $stats); return $stats; } @@ -138,7 +139,7 @@ function cpu_usage() { return $cpuUsage; } -function get_pfstate() { +function get_pfstate($percent=false) { global $config; $matches = ""; if (isset($config['system']['maximumstates']) and $config['system']['maximumstates'] > 0) @@ -149,7 +150,10 @@ function get_pfstate() { if (preg_match("/([0-9]+)/", $curentries, $matches)) { $curentries = $matches[1]; } - return $curentries . "/" . $maxstates; + if ($percent) + return ($curentries / $maxstates) * 100; + else + return $curentries . "/" . $maxstates; } function has_temp() { diff --git a/usr/local/www/javascript/index/ajax.js b/usr/local/www/javascript/index/ajax.js index d2a6536..3bfd67b 100644 --- a/usr/local/www/javascript/index/ajax.js +++ b/usr/local/www/javascript/index/ajax.js @@ -44,6 +44,7 @@ function stats(x) { updateCpuFreq(values[9]); updateLoadAverage(values[10]); updateMbuf(values[11]); + updateStateMeter(values[12]); } function updateMemory(x) { @@ -101,6 +102,15 @@ function updateState(x) { jQuery("#pfstate").html(x); } +function updateStateMeter(x) { + if(jQuery('#pfstateusagemeter')) + jQuery("#pfstateusagemeter").html(x + '%'); + if(jQuery('#pfstatewidtha')) + jQuery("#pfstatewidtha").css('width',x + 'px'); + if(jQuery('#pfstatewidthb')) + jQuery("#pfstatewidthb").css('width',(100 - x) + 'px'); +} + function updateGatewayStats(x){ if (widgetActive("gateways")){ gateways_split = x.split(","); diff --git a/usr/local/www/widgets/widgets/system_information.widget.php b/usr/local/www/widgets/widgets/system_information.widget.php index 208c641..3305859 100644 --- a/usr/local/www/widgets/widgets/system_information.widget.php +++ b/usr/local/www/widgets/widgets/system_information.widget.php @@ -186,7 +186,11 @@ $curcfg = $config['system']['firmware']; State table size - + + left barred bargray barright bar +
()
Show states -- cgit v1.1