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(-) (limited to 'usr/local') 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