From 54f818b16f18c73b0b2689239a94abbce337cd13 Mon Sep 17 00:00:00 2001 From: Joecowboy Date: Thu, 5 Jan 2012 17:56:17 -0600 Subject: Changed the output of function get_uptime() to display: 00 Hours 00 Minutes 00 Seconds Added code function get_temp() to get the OID values for temperature. --- usr/local/www/includes/functions.inc.php | 40 +++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/usr/local/www/includes/functions.inc.php b/usr/local/www/includes/functions.inc.php index 6769d0e..041fd55 100644 --- a/usr/local/www/includes/functions.inc.php +++ b/usr/local/www/includes/functions.inc.php @@ -86,13 +86,31 @@ function get_uptime() { $uphours = (int)($uptime / 3600); $uptime %= 3600; $upmins = (int)($uptime / 60); + $uptime %= 60; + $upsecs = (int)($uptime); $uptimestr = ""; if ($updays > 1) - $uptimestr .= "$updays days, "; + $uptimestr .= "$updays Days "; else if ($updays > 0) - $uptimestr .= "1 day, "; - $uptimestr .= sprintf("%02d:%02d", $uphours, $upmins); + $uptimestr .= "1 Day "; + + if ($uphours > 1) + $hours = "Hours"; + else if ($uphours > 0) + $hours = "Hour"; + + if ($upmins > 1) + $minutes = "Minutes"; + else if ($uphours > 0) + $minutes = "Minute"; + + if ($upmins > 1) + $seconds = "Seconds"; + else if ($uphours > 0) + $seconds = "Second"; + + $uptimestr .= sprintf("%02d $hours %02d $minutes %02d $seconds", $uphours, $upmins, $upsecs); return $uptimestr; } @@ -148,12 +166,22 @@ function get_hwtype() { } function get_temp() { - switch(get_hwtype()) { + /*switch(get_hwtype()) { default: return; } - return $ret; + return $ret; */ + + $temp_out = ""; + exec("/sbin/sysctl dev.cpu.0.temperature | /usr/bin/awk '{ print $2 }' | /usr/bin/cut -d 'C' -f 1", $dfout); + $temp_out = trim($dfout[0]); + if ($temp_out == "") { + exec("/sbin/sysctl hw.acpi.thermal.tz0.temperature | /usr/bin/awk '{ print $2 }' | /usr/bin/cut -d 'C' -f 1", $dfout); + $temp_out = trim($dfout[0]); + } + + return $temp_out; } function disk_usage() @@ -264,4 +292,4 @@ function get_interfacestatus() { return $data; } -?> +?> \ No newline at end of file -- cgit v1.1 From e54d3461b47dd6610f2a4a95c7e38a2740f5291f Mon Sep 17 00:00:00 2001 From: Joecowboy Date: Thu, 5 Jan 2012 18:04:57 -0600 Subject: Fixed Javascript error in function updateInterfaces(x) Removed the return that revented the updates to widgets in function stats(x) Tweaked Javascript code in function updateTemp(x) for temperature output --- usr/local/www/javascript/index/ajax.js | 47 ++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/usr/local/www/javascript/index/ajax.js b/usr/local/www/javascript/index/ajax.js index 1759c05..bafdbff 100644 --- a/usr/local/www/javascript/index/ajax.js +++ b/usr/local/www/javascript/index/ajax.js @@ -1,9 +1,9 @@ - /* Most widgets update their backend data every 10 seconds. 11 seconds * will ensure that we update the GUI right after the stats are updated. * Seconds * 1000 = value */ -var update_interval = 11000; +var Seconds = 11; +var update_interval = (Math.abs(Math.ceil(Seconds))-1)*1000 + 990; function updateMeters() { url = '/getstats.php'; @@ -16,7 +16,11 @@ function updateMeters() { stats(data); } }); - setTimeout('updateMeters()', update_interval); + setTimer(); +} + +function setTimer() { + timeout = window.setTimeout('updateMeters()', update_interval); } function stats(x) { @@ -27,17 +31,16 @@ function stats(x) { else return false; })) - return; - - updateCPU(values[0]); - updateMemory(values[1]); - updateUptime(values[2]); - updateState(values[3]); - updateTemp(values[4]); - updateDateTime(values[5]); - updateInterfaceStats(values[6]); - updateInterfaces(values[7]); - updateGatewayStats(values[8]); + + updateUptime(values[2]); + updateDateTime(values[5]); + updateCPU(values[0]); + updateMemory(values[1]); + updateState(values[3]); + updateTemp(values[4]); + updateInterfaceStats(values[6]); + updateInterfaces(values[7]); + updateGatewayStats(values[8]); } function updateMemory(x) { @@ -63,11 +66,12 @@ function updateCPU(x) { } function updateTemp(x) { - if(jQuery("#tempmeter")) { - jQuery("#tempmeter").val(x + 'C'); + if(jQuery("#tempmeter")) + jQuery("#tempmeter").val(x + '\u00B0' + 'C'); + if(jQuery('#tempwidtha')) jQuery("#tempwidtha").css('width',x + 'px'); + if(jQuery('#tempwidthb')) jQuery("#tempwidthb").css('width',(100 - x) + 'px'); - } } function updateDateTime(x) { @@ -111,8 +115,8 @@ function updateInterfaceStats(x){ function updateInterfaces(x){ if (widgetActive("interfaces")){ - interfaces = x.split("~"); - interfaces.each(function(iface){ + interfaces_split = x.split("~"); + interfaces_split.each(function(iface){ details = iface.split(","); switch(details[1]) { case "up": @@ -149,6 +153,5 @@ function widgetActive(x) { /* start updater */ jQuery(document).ready(function(){ - setTimeout('updateMeters()', update_interval); -}); - + setTimer(); +}); \ No newline at end of file -- cgit v1.1 From e7d6136d86f0bc15d35d909245cc3512abd12199 Mon Sep 17 00:00:00 2001 From: Joecowboy Date: Thu, 5 Jan 2012 18:12:25 -0600 Subject: Tweaked the bar graph width. --- usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php b/usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php index fa48610..a7e7882 100644 --- a/usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php +++ b/usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php @@ -61,12 +61,12 @@ require_once("functions.inc"); + \ No newline at end of file -- cgit v1.1 From 24d515348cde4f865fb585a6b86e9d042fd6fef8 Mon Sep 17 00:00:00 2001 From: Joecowboy Date: Thu, 5 Jan 2012 18:16:23 -0600 Subject: Added Temperature back in --- usr/local/www/widgets/widgets/system_information.widget.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/usr/local/www/widgets/widgets/system_information.widget.php b/usr/local/www/widgets/widgets/system_information.widget.php index 9945539..0194c58 100644 --- a/usr/local/www/widgets/widgets/system_information.widget.php +++ b/usr/local/www/widgets/widgets/system_information.widget.php @@ -200,6 +200,15 @@ $curcfg = $config['system']['firmware']; / + + Temperature + + + left barred bargray barright bar +   + " /> + + CPU usage @@ -275,4 +284,4 @@ $curcfg = $config['system']['firmware']; jQuery('#uname').html(""); } setTimeout('getstatus()', 4000); - + \ No newline at end of file -- cgit v1.1 From cbac040da55e6cb806d24366488ca100a6ce7d55 Mon Sep 17 00:00:00 2001 From: Joecowboy Date: Thu, 5 Jan 2012 18:21:13 -0600 Subject: Disabled the line jQuery('#' + graph['spans'][count - 1]).fadeIn(500); causing javascript error exception to be thrown while displaying span --- usr/local/www/widgets/javascript/cpu_graphs.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/usr/local/www/widgets/javascript/cpu_graphs.js b/usr/local/www/widgets/javascript/cpu_graphs.js index a411912..3d91b5f 100644 --- a/usr/local/www/widgets/javascript/cpu_graphs.js +++ b/usr/local/www/widgets/javascript/cpu_graphs.js @@ -242,6 +242,5 @@ function GraphDraw(graph) { for(var i = 0; i < count; i++) graph['spans'][i].style.marginTop = getMargin(i); - jQuery('#' + graph['spans'][count - 1]).fadeIn(500); -} - +// jQuery('#' + graph['spans'][count - 1]).fadeIn(500); +} \ No newline at end of file -- cgit v1.1 From 135a095656d54923ed52146259782404b05698e1 Mon Sep 17 00:00:00 2001 From: Joecowboy Date: Thu, 5 Jan 2012 19:13:50 -0600 Subject: Update usr/local/www/widgets/widgets/system_information.widget.php --- usr/local/www/widgets/widgets/system_information.widget.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr/local/www/widgets/widgets/system_information.widget.php b/usr/local/www/widgets/widgets/system_information.widget.php index 0194c58..757e5c8 100644 --- a/usr/local/www/widgets/widgets/system_information.widget.php +++ b/usr/local/www/widgets/widgets/system_information.widget.php @@ -200,15 +200,17 @@ $curcfg = $config['system']['firmware']; / + Temperature - + left barred bargray barright bar   " /> + CPU usage -- cgit v1.1 From b10268ca95b930ca2bda29016fcb32ec8eb7aa3e Mon Sep 17 00:00:00 2001 From: Joecowboy Date: Thu, 5 Jan 2012 21:30:16 -0600 Subject: Fixed the get_time() out put fixed. Tweaked my changes made a tighter code. --- usr/local/www/includes/functions.inc.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/usr/local/www/includes/functions.inc.php b/usr/local/www/includes/functions.inc.php index 041fd55..961f925 100644 --- a/usr/local/www/includes/functions.inc.php +++ b/usr/local/www/includes/functions.inc.php @@ -96,21 +96,15 @@ function get_uptime() { $uptimestr .= "1 Day "; if ($uphours > 1) - $hours = "Hours"; - else if ($uphours > 0) - $hours = "Hour"; - + $hours = "s"; + if ($upmins > 1) - $minutes = "Minutes"; - else if ($uphours > 0) - $minutes = "Minute"; - + $minutes = "s"; + if ($upmins > 1) - $seconds = "Seconds"; - else if ($uphours > 0) - $seconds = "Second"; - - $uptimestr .= sprintf("%02d $hours %02d $minutes %02d $seconds", $uphours, $upmins, $upsecs); + $seconds = "s"; + + $uptimestr .= sprintf("%02d Hour$hours %02d Minute$minutes %02d Second$seconds", $uphours, $upmins, $upsecs); return $uptimestr; } -- cgit v1.1 From e9ca9b9a35c5e7c9c2fb6025c54da420d901cc49 Mon Sep 17 00:00:00 2001 From: Joecowboy Date: Fri, 6 Jan 2012 10:34:33 -0600 Subject: I did a block comment out the fist time because I wanted to leave that code in for later use when start adding more OID checks for different hardware drivers. So made comment change per request. --- usr/local/www/includes/functions.inc.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/usr/local/www/includes/functions.inc.php b/usr/local/www/includes/functions.inc.php index 961f925..8ceea4d 100644 --- a/usr/local/www/includes/functions.inc.php +++ b/usr/local/www/includes/functions.inc.php @@ -160,12 +160,12 @@ function get_hwtype() { } function get_temp() { - /*switch(get_hwtype()) { - default: - return; - } - - return $ret; */ +// switch(get_hwtype()) { +// default: +// return; +// } +// +// return $ret; $temp_out = ""; exec("/sbin/sysctl dev.cpu.0.temperature | /usr/bin/awk '{ print $2 }' | /usr/bin/cut -d 'C' -f 1", $dfout); -- cgit v1.1