From 25a46a3cb249ea3eeb8319e5ab161dfd3c5160ae Mon Sep 17 00:00:00 2001 From: Cristian Feldman Date: Thu, 24 May 2012 18:52:27 -0300 Subject: Added load average information to the System Information widget --- usr/local/www/includes/functions.inc.php | 8 ++++++++ usr/local/www/javascript/index/ajax.js | 6 ++++++ usr/local/www/widgets/widgets/system_information.widget.php | 6 ++++++ 3 files changed, 20 insertions(+) (limited to 'usr') diff --git a/usr/local/www/includes/functions.inc.php b/usr/local/www/includes/functions.inc.php index 3039c35..806a084 100644 --- a/usr/local/www/includes/functions.inc.php +++ b/usr/local/www/includes/functions.inc.php @@ -20,6 +20,7 @@ function get_stats() { $stats['interfacestatus'] = get_interfacestatus(); $stats['gateways'] = get_gatewaystats(); $stats['cpufreq'] = get_cpufreq(); + $stats['load_average'] = get_load_average(); $stats = join("|", $stats); return $stats; } @@ -231,6 +232,13 @@ function get_cpufreq() { return $out; } + +function get_load_average() { + $load_average = ""; + exec("/usr/bin/uptime | /usr/bin/sed 's/^.*: //'", $load_average); + return $load_average[0]; +} + function get_interfacestats() { global $config; diff --git a/usr/local/www/javascript/index/ajax.js b/usr/local/www/javascript/index/ajax.js index eab0119..5cae407 100644 --- a/usr/local/www/javascript/index/ajax.js +++ b/usr/local/www/javascript/index/ajax.js @@ -42,6 +42,7 @@ function stats(x) { updateInterfaces(values[7]); updateGatewayStats(values[8]); updateCpuFreq(values[9]); + updateLoadAverage(values[10]); } function updateMemory(x) { @@ -106,6 +107,11 @@ function updateCpuFreq(x) { jQuery("#cpufreq").html(x); } +function updateLoadAverage(x) { + if(jQuery('#load_average')) + jQuery("#load_average").html(x); +} + function updateInterfaceStats(x){ if (widgetActive("interface_statistics")){ statistics_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 776679a..f057866 100644 --- a/usr/local/www/widgets/widgets/system_information.widget.php +++ b/usr/local/www/widgets/widgets/system_information.widget.php @@ -202,6 +202,12 @@ $curcfg = $config['system']['firmware']; + Load average + +
+ + + CPU usage -- cgit v1.1