From 0dd523be45f00e8c3346a2ac9a91aa62948fd004 Mon Sep 17 00:00:00 2001 From: crcro Date: Thu, 15 Sep 2016 19:37:52 +0300 Subject: [PATCH 1/5] app-ups-nut update 1 --- .../graphs/application/ups-nut_remaining.inc.php | 6 +++++- .../application/ups-nut_voltage_battery.inc.php | 7 +++++-- html/pages/device/apps/ups-nut.inc.php | 4 ++-- includes/polling/applications/ups-nut.inc.php | 16 ++++++++++------ 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/html/includes/graphs/application/ups-nut_remaining.inc.php b/html/includes/graphs/application/ups-nut_remaining.inc.php index 44c00b1ccd..bbd5ca04ad 100644 --- a/html/includes/graphs/application/ups-nut_remaining.inc.php +++ b/html/includes/graphs/application/ups-nut_remaining.inc.php @@ -13,10 +13,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * +* @version 1.1 * @package LibreNMS * @link http://librenms.org * @copyright 2016 crcro * @author Cercel Valentin +* +* v1 - initial release +* v1.1 - changed description from seconds to minutes */ require 'includes/graphs/common.inc.php'; @@ -27,7 +31,7 @@ $colour_area = 'EEEEEE'; $colour_line = '36393D'; $colour_area_max = 'FFEE99'; $graph_max = 0; -$unit_text = 'Seconds'; +$unit_text = 'Minutes'; $ups_nut = rrd_name($device['hostname'], array('app', 'ups-nut', $app['app_id'])); if (rrdtool_check_rrd_exists($ups_nut)) { $rrd_filename = $ups_nut; diff --git a/html/includes/graphs/application/ups-nut_voltage_battery.inc.php b/html/includes/graphs/application/ups-nut_voltage_battery.inc.php index 08d2e18927..5221dcb9b4 100644 --- a/html/includes/graphs/application/ups-nut_voltage_battery.inc.php +++ b/html/includes/graphs/application/ups-nut_voltage_battery.inc.php @@ -13,10 +13,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * +* @version 1.1 * @package LibreNMS * @link http://librenms.org * @copyright 2016 crcro * @author Cercel Valentin +* +* v1 - initial release +* v1.1 - removed the battery_low graph */ require 'includes/graphs/common.inc.php'; @@ -33,7 +37,6 @@ $addarea = 1; $transparency = 33; $rrd_filename = rrd_name($device['hostname'], array('app', 'ups-nut', $app['app_id'])); $array = array( - 'battery_low' => array('descr' => 'Low','colour' => '630606',), 'battery_voltage' => array('descr' => 'Current','colour' => '50C150',), ); @@ -48,7 +51,7 @@ if (rrdtool_check_rrd_exists($rrd_filename)) { $i++; } } else { - echo "file missing: $rrd_filename"; + echo "file missing: ".$rrd_filename; } require 'includes/graphs/generic_v3_multiline_float.inc.php'; diff --git a/html/pages/device/apps/ups-nut.inc.php b/html/pages/device/apps/ups-nut.inc.php index 8dd01b7e2a..ab0eaf8549 100644 --- a/html/pages/device/apps/ups-nut.inc.php +++ b/html/pages/device/apps/ups-nut.inc.php @@ -22,8 +22,8 @@ global $config; //NET-SNMP-EXTEND-MIB::nsExtendOutLine.\"ups-nut\" -$ups_model = snmp_get($device, '.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.5', '-Oqv'); -$ups_serial = snmp_get($device, '.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.6', '-Oqv'); +$ups_model = snmp_get($device, '.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.4', '-Oqv'); +$ups_serial = snmp_get($device, '.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.5', '-Oqv'); $ups_details = $ups_model.' (SN:'.$ups_serial.')'; $graphs = array( diff --git a/includes/polling/applications/ups-nut.inc.php b/includes/polling/applications/ups-nut.inc.php index c19a1f2e23..0b9400cff0 100644 --- a/includes/polling/applications/ups-nut.inc.php +++ b/includes/polling/applications/ups-nut.inc.php @@ -13,10 +13,16 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * +* @version 1.1 * @package LibreNMS * @link http://librenms.org * @copyright 2016 crcro * @author Cercel Valentin +* +* v1 - initial release +* v1.1 - removed battery_low value +* - corrected line nominal and input values +* - convert seconds to minutes on remaining uptime */ //NET-SNMP-EXTEND-MIB::nsExtendOutputFull."ups-nut" @@ -27,12 +33,11 @@ $ups_nut = snmp_get($device, $oid, '-Oqv'); echo ' '.$name; -list ($charge, $bat_low, $remaining, $bat_volt, $model, $serial, $input_vol, $line_vol, $load) = explode("\n", $ups_nut); +list ($charge, $remaining, $bat_volt, $model, $serial, $input_volt, $line_volt, $load) = explode("\n", $ups_nut); $rrd_name = array('app', $name, $app_id); $rrd_def = array( 'DS:charge:GAUGE:600:0:100', - 'DS:battery_low:GAUGE:600:0:100', 'DS:time_remaining:GAUGE:600:0:U', 'DS:battery_voltage:GAUGE:600:0:U', 'DS:input_voltage:GAUGE:600:0:U', @@ -42,11 +47,10 @@ $rrd_def = array( $fields = array( 'charge' => $charge, - 'battery_low' => $bat_low, - 'time_remaining' => $remaining, + 'time_remaining' => $remaining/60, 'battery_voltage' => $bat_volt, - 'input_voltage' => $input_vol, - 'nominal_voltage' => $line_vol, + 'input_voltage' => $line_volt, + 'nominal_voltage' => $input_volt, 'load' => $load, ); From 7d7621fd3e03b86eddc4777e31c611ef46dd299d Mon Sep 17 00:00:00 2001 From: crcro Date: Thu, 15 Sep 2016 23:24:25 +0300 Subject: [PATCH 2/5] removed file versions from comments --- html/includes/graphs/application/ups-nut_remaining.inc.php | 3 --- .../graphs/application/ups-nut_voltage_battery.inc.php | 3 --- html/pages/device/apps/ups-nut.inc.php | 1 + includes/polling/applications/ups-nut.inc.php | 4 ---- 4 files changed, 1 insertion(+), 10 deletions(-) diff --git a/html/includes/graphs/application/ups-nut_remaining.inc.php b/html/includes/graphs/application/ups-nut_remaining.inc.php index bbd5ca04ad..c566388c21 100644 --- a/html/includes/graphs/application/ups-nut_remaining.inc.php +++ b/html/includes/graphs/application/ups-nut_remaining.inc.php @@ -13,14 +13,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * -* @version 1.1 * @package LibreNMS * @link http://librenms.org * @copyright 2016 crcro * @author Cercel Valentin * -* v1 - initial release -* v1.1 - changed description from seconds to minutes */ require 'includes/graphs/common.inc.php'; diff --git a/html/includes/graphs/application/ups-nut_voltage_battery.inc.php b/html/includes/graphs/application/ups-nut_voltage_battery.inc.php index 5221dcb9b4..659e79d763 100644 --- a/html/includes/graphs/application/ups-nut_voltage_battery.inc.php +++ b/html/includes/graphs/application/ups-nut_voltage_battery.inc.php @@ -13,14 +13,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * -* @version 1.1 * @package LibreNMS * @link http://librenms.org * @copyright 2016 crcro * @author Cercel Valentin * -* v1 - initial release -* v1.1 - removed the battery_low graph */ require 'includes/graphs/common.inc.php'; diff --git a/html/pages/device/apps/ups-nut.inc.php b/html/pages/device/apps/ups-nut.inc.php index ab0eaf8549..78e1d23917 100644 --- a/html/pages/device/apps/ups-nut.inc.php +++ b/html/pages/device/apps/ups-nut.inc.php @@ -17,6 +17,7 @@ * @link http://librenms.org * @copyright 2016 crcro * @author Cercel Valentin +* */ global $config; diff --git a/includes/polling/applications/ups-nut.inc.php b/includes/polling/applications/ups-nut.inc.php index 0b9400cff0..142c91a6f7 100644 --- a/includes/polling/applications/ups-nut.inc.php +++ b/includes/polling/applications/ups-nut.inc.php @@ -19,10 +19,6 @@ * @copyright 2016 crcro * @author Cercel Valentin * -* v1 - initial release -* v1.1 - removed battery_low value -* - corrected line nominal and input values -* - convert seconds to minutes on remaining uptime */ //NET-SNMP-EXTEND-MIB::nsExtendOutputFull."ups-nut" From 780d8b2139d6b9485ed7688eb0e074e869b491a7 Mon Sep 17 00:00:00 2001 From: crcro Date: Tue, 20 Sep 2016 22:01:29 +0300 Subject: [PATCH 3/5] removed snmp query from webui, changed and added echo if file is missing --- .../graphs/application/ups-nut_charge.inc.php | 3 +++ .../graphs/application/ups-nut_load.inc.php | 3 +++ .../graphs/application/ups-nut_remaining.inc.php | 3 +++ .../application/ups-nut_voltage_battery.inc.php | 2 +- html/pages/device/apps/ups-nut.inc.php | 15 +++++---------- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/html/includes/graphs/application/ups-nut_charge.inc.php b/html/includes/graphs/application/ups-nut_charge.inc.php index 130ebdd62e..040d4c861b 100644 --- a/html/includes/graphs/application/ups-nut_charge.inc.php +++ b/html/includes/graphs/application/ups-nut_charge.inc.php @@ -31,5 +31,8 @@ $unit_text = 'Percent'; $ups_nut = rrd_name($device['hostname'], array('app', 'ups-nut', $app['app_id'])); if (rrdtool_check_rrd_exists($ups_nut)) { $rrd_filename = $ups_nut; +} else { + echo "file missing: $rrd_filename"; } + require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/application/ups-nut_load.inc.php b/html/includes/graphs/application/ups-nut_load.inc.php index c678aa5ff8..2530f23d08 100644 --- a/html/includes/graphs/application/ups-nut_load.inc.php +++ b/html/includes/graphs/application/ups-nut_load.inc.php @@ -31,5 +31,8 @@ $unit_text = 'Percent'; $ups_nut = rrd_name($device['hostname'], array('app', 'ups-nut', $app['app_id'])); if (rrdtool_check_rrd_exists($ups_nut)) { $rrd_filename = $ups_nut; +} else { + echo "file missing: $rrd_filename"; } + require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/application/ups-nut_remaining.inc.php b/html/includes/graphs/application/ups-nut_remaining.inc.php index c566388c21..16c3b3289d 100644 --- a/html/includes/graphs/application/ups-nut_remaining.inc.php +++ b/html/includes/graphs/application/ups-nut_remaining.inc.php @@ -32,5 +32,8 @@ $unit_text = 'Minutes'; $ups_nut = rrd_name($device['hostname'], array('app', 'ups-nut', $app['app_id'])); if (rrdtool_check_rrd_exists($ups_nut)) { $rrd_filename = $ups_nut; +} else { + echo "file missing: $rrd_filename"; } + require 'includes/graphs/generic_simplex.inc.php'; diff --git a/html/includes/graphs/application/ups-nut_voltage_battery.inc.php b/html/includes/graphs/application/ups-nut_voltage_battery.inc.php index 659e79d763..a00946c450 100644 --- a/html/includes/graphs/application/ups-nut_voltage_battery.inc.php +++ b/html/includes/graphs/application/ups-nut_voltage_battery.inc.php @@ -48,7 +48,7 @@ if (rrdtool_check_rrd_exists($rrd_filename)) { $i++; } } else { - echo "file missing: ".$rrd_filename; + echo "file missing: $rrd_filename"; } require 'includes/graphs/generic_v3_multiline_float.inc.php'; diff --git a/html/pages/device/apps/ups-nut.inc.php b/html/pages/device/apps/ups-nut.inc.php index 78e1d23917..13285ae384 100644 --- a/html/pages/device/apps/ups-nut.inc.php +++ b/html/pages/device/apps/ups-nut.inc.php @@ -22,17 +22,12 @@ global $config; -//NET-SNMP-EXTEND-MIB::nsExtendOutLine.\"ups-nut\" -$ups_model = snmp_get($device, '.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.4', '-Oqv'); -$ups_serial = snmp_get($device, '.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.117.112.115.45.110.117.116.5', '-Oqv'); -$ups_details = $ups_model.' (SN:'.$ups_serial.')'; - $graphs = array( - 'ups-nut_remaining' => 'Remaining time: '.$ups_details, - 'ups-nut_load' => 'Load: '.$ups_details, - 'ups-nut_voltage_battery' => 'Battery voltage: '.$ups_details, - 'ups-nut_charge' => 'Charge: '.$ups_details, - 'ups-nut_voltage_input' => 'Input voltage: '.$ups_details, + 'ups-nut_remaining' => 'Remaining time: ', + 'ups-nut_load' => 'Load: ', + 'ups-nut_voltage_battery' => 'Battery voltage: ', + 'ups-nut_charge' => 'Charge: ', + 'ups-nut_voltage_input' => 'Input voltage: ', ); foreach ($graphs as $key => $text) { From 0eea1801514b33a50e3686310ea449c2524bab3d Mon Sep 17 00:00:00 2001 From: crcro Date: Tue, 20 Sep 2016 22:03:30 +0300 Subject: [PATCH 4/5] removed file version and unused vars --- includes/polling/applications/ups-nut.inc.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/includes/polling/applications/ups-nut.inc.php b/includes/polling/applications/ups-nut.inc.php index 142c91a6f7..721d0923fe 100644 --- a/includes/polling/applications/ups-nut.inc.php +++ b/includes/polling/applications/ups-nut.inc.php @@ -13,7 +13,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * -* @version 1.1 * @package LibreNMS * @link http://librenms.org * @copyright 2016 crcro @@ -29,7 +28,7 @@ $ups_nut = snmp_get($device, $oid, '-Oqv'); echo ' '.$name; -list ($charge, $remaining, $bat_volt, $model, $serial, $input_volt, $line_volt, $load) = explode("\n", $ups_nut); +list ($charge, $remaining, $bat_volt, $input_volt, $line_volt, $load) = explode("\n", $ups_nut); $rrd_name = array('app', $name, $app_id); $rrd_def = array( From f87043eca7483563d487388eb8ad7eb3cba9118d Mon Sep 17 00:00:00 2001 From: crcro Date: Sat, 24 Sep 2016 20:09:27 +0300 Subject: [PATCH 5/5] readded ds --- includes/polling/applications/ups-nut.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/polling/applications/ups-nut.inc.php b/includes/polling/applications/ups-nut.inc.php index 721d0923fe..66509e3222 100644 --- a/includes/polling/applications/ups-nut.inc.php +++ b/includes/polling/applications/ups-nut.inc.php @@ -28,11 +28,12 @@ $ups_nut = snmp_get($device, $oid, '-Oqv'); echo ' '.$name; -list ($charge, $remaining, $bat_volt, $input_volt, $line_volt, $load) = explode("\n", $ups_nut); +list ($charge, $battery_low, $remaining, $bat_volt, $input_volt, $line_volt, $load) = explode("\n", $ups_nut); $rrd_name = array('app', $name, $app_id); $rrd_def = array( 'DS:charge:GAUGE:600:0:100', + 'DS:battery_low:GAUGE:600:0:100', 'DS:time_remaining:GAUGE:600:0:U', 'DS:battery_voltage:GAUGE:600:0:U', 'DS:input_voltage:GAUGE:600:0:U', @@ -42,6 +43,7 @@ $rrd_def = array( $fields = array( 'charge' => $charge, + 'battery_low' => $battery_low, 'time_remaining' => $remaining/60, 'battery_voltage' => $bat_volt, 'input_voltage' => $line_volt,