From ab8da3d74a9a2b066045d371f239da47eae11656 Mon Sep 17 00:00:00 2001 From: Ryan Wagoner Date: Thu, 15 Feb 2007 20:53:58 +0000 Subject: -add status support for remote ups -display status in table format -add model, temperature, and load information --- packages/nut/status_nut.php | 55 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/packages/nut/status_nut.php b/packages/nut/status_nut.php index 2a7c800d..c5afcdfe 100644 --- a/packages/nut/status_nut.php +++ b/packages/nut/status_nut.php @@ -3,7 +3,7 @@ status_nut.php part of pfSense (http://www.pfsense.com/) - Copyright (C) 2006 Ryan Wagoner . + Copyright (C) 2007 Ryan Wagoner . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -60,11 +60,18 @@ include("head.inc"); -
+ + \n"); $handle = popen("upsc {$nut_config['name']}@localhost","r"); + } elseif($nut_config['monitor'] == 'remote') { + print("\n"); + $handle = popen("upsc {$nut_config['remotename']}@{$nut_config['remoteaddr']}","r"); + } + + if($handle) { $read = fread($handle, 4096); pclose($handle); @@ -73,21 +80,47 @@ include("head.inc"); $ups = array(); foreach($read as $line) { $line = explode(':', $line); - $ups[$line[0]] = $line[1]; + $ups[$line[0]] = trim($line[1]); } + + print("\n"); - print("Status: {$ups['ups.status']}
"); - print("Battery Charge: {$ups['battery.charge']}
"); - print("Battery Voltage: {$ups['battery.voltage']}
"); - print("Input Voltage: {$ups['input.voltage']}
"); - print("Output Voltage: {$ups['output.voltage']}
"); - - /*print('
'); print_r($ups); print('
');*/ + print('\n"); + + print("\n"); + print("\n"); + print("\n"); + print("\n"); + print("\n"); + print("\n"); + } else { + /* display error */ + print("\n"); } ?> +
Monitoring:Local UPS
Monitoring:Remote UPS
Model:{$ups['ups.model']}
Status:'); + $status = explode(' ',$ups['ups.status']); + foreach($status as $condition) { + switch ($condition) { + case WAIT: + print('Waiting... '); + break; + case OL: + print('On Line '); + break; + case LB: + print('Battery Low '); + break; + } + } + print("
Load:{$ups['ups.load']}%
Battery Charge:{$ups['battery.charge']}%
Battery Voltage:{$ups['battery.voltage']}
Input Voltage:{$ups['input.voltage']}V
Output Voltage:{$ups['output.voltage']}V
Temperature:{$ups['ups.temperature']}
ERROR:Can\'t parse data from upsc!
+'); print_r($ups); print('');*/ +?> -- cgit v1.2.3