aboutsummaryrefslogtreecommitdiffstats
path: root/packages/nut/status_nut.php
diff options
context:
space:
mode:
authorRyan Wagoner <rsw686@pfsense.org>2007-02-18 02:58:30 +0000
committerRyan Wagoner <rsw686@pfsense.org>2007-02-18 02:58:30 +0000
commit85c7126700fbe758b6087f80af2a98ac95ab8ccd (patch)
treef1c2457ef6d5d71da3421bdc12cf8fbfc9ee2f21 /packages/nut/status_nut.php
parentf16f2b6be9c3084a6523d3ce8b1b853abcef8583 (diff)
downloadpfsense-packages-85c7126700fbe758b6087f80af2a98ac95ab8ccd.tar.gz
pfsense-packages-85c7126700fbe758b6087f80af2a98ac95ab8ccd.tar.bz2
pfsense-packages-85c7126700fbe758b6087f80af2a98ac95ab8ccd.zip
- only show values reported by upsc
- change text color so its readable and format values correctly
Diffstat (limited to 'packages/nut/status_nut.php')
-rw-r--r--packages/nut/status_nut.php56
1 files changed, 38 insertions, 18 deletions
diff --git a/packages/nut/status_nut.php b/packages/nut/status_nut.php
index 2d16c0ec..14ba84f8 100644
--- a/packages/nut/status_nut.php
+++ b/packages/nut/status_nut.php
@@ -34,7 +34,12 @@ $nut_config = $config['installedpackages']['nut']['config'][0];
/* functions */
-function tblrow ($name, $value) {
+function tblrow ($name, $value, $symbol = null) {
+ if(!$value) return;
+
+ if($symbol == '&deg;')
+ $value = sprintf("%.1f", $value);
+
print(<<<EOD
<tr>
<td class="vncellreq" width="100px">{$name}</td>
@@ -45,15 +50,23 @@ EOD
}
function tblrowbar ($name, $value, $symbol, $red, $yellow, $green) {
- $red = explode('-',$red);
- $yellow = explode('-',$yellow);
- $green = explode('-',$green);
+ if(!$value) return;
+
+ $value = sprintf("%.1f", $value);
+
+ $red = explode('-', $red);
+ $yellow = explode('-', $yellow);
+ $green = explode('-', $green);
sort($red);
sort($yellow);
sort($green);
- if($value >= $red[0] && $value <= $red[1]) {
+ if($value >= $red[0] && $value <= ($red[0]+9)) {
+ $color = 'black';
+ $bgcolor = 'red';
+ }
+ if($value >= ($red[0]+10) && $value <= $red[1]) {
$color = 'white';
$bgcolor = 'red';
}
@@ -61,7 +74,11 @@ function tblrowbar ($name, $value, $symbol, $red, $yellow, $green) {
$color = 'black';
$bgcolor = 'yellow';
}
- if($value >= $green[0] && $value <= $green[1]) {
+ if($value >= $green[0] && $value <= ($green[0]+9)) {
+ $color = 'black';
+ $bgcolor = 'green';
+ }
+ if($value >= ($green[0]+10) && $value <= $green[1]) {
$color = 'white';
$bgcolor = 'green';
}
@@ -125,22 +142,25 @@ include("head.inc");
pclose($handle);
/* parse upsc into array */
- $read = explode("\n",$read);
+ $read = explode("\n", $read);
$ups = array();
foreach($read as $line) {
$line = explode(':', $line);
$ups[$line[0]] = trim($line[1]);
}
- tblrow('Model:',$ups['ups.model']);
+ tblrow('Model:', $ups['ups.model']);
- $status = explode(' ',$ups['ups.status']);
+ $status = explode(' ', $ups['ups.status']);
foreach($status as $condition) {
if($disp_status) $disp_status .= ', ';
switch ($condition) {
case 'WAIT':
$disp_status .= 'Waiting';
break;
+ case 'OFF':
+ $disp_status .= 'Off Line';
+ break;
case 'OL':
$disp_status .= 'On Line';
break;
@@ -170,17 +190,17 @@ include("head.inc");
break;
}
}
- tblrow('Status:',$disp_status);
-
- tblrowbar('Load:',$ups['ups.load'],'%','100-80','79-60','59-0');
- tblrowbar('Battery Charge:',$ups['battery.charge'],'%','0-29','30-79','80-100');
- tblrow('Battery Voltage:',$ups['battery.voltage'].'V');
- tblrow('Input Voltage:',$ups['input.voltage'].'V');
- tblrow('Output Voltage:',$ups['output.voltage'].'V');
- tblrow('Temperature:',$ups['ups.temperature'].'&deg;');
+ tblrow('Status:', $disp_status);
+
+ tblrowbar('Load:', $ups['ups.load'], '%', '100-80', '79-60', '59-0');
+ tblrowbar('Battery Charge:', $ups['battery.charge'], '%', '0-29' ,'30-79', '80-100');
+ tblrow('Battery Voltage:', $ups['battery.voltage'], 'V');
+ tblrow('Input Voltage:', $ups['input.voltage'], 'V');
+ tblrow('Output Voltage:', $ups['output.voltage'], 'V');
+ tblrow('Temperature:', $ups['ups.temperature'], '&deg;');
} else {
/* display error */
- tblrow('ERROR:','Can\'t parse data from upsc!');
+ tblrow('ERROR:', 'Can\'t parse data from upsc');
}
?>
</table>