From ac790caaf0ffd589ca26ac8a5b99c7d71e613bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Rosiak?= Date: Fri, 6 Jan 2017 23:42:04 +0200 Subject: [PATCH] newdevice: Added additional detection for Dell UPS (#5322) --- .../discovery/sensors/power/dell-ups.inc.php | 21 ++++++++ .../sensors/runtime/dell-ups.inc.php | 27 ++++++++++ .../discovery/sensors/states/dell-ups.inc.php | 52 +++++++++++++++++++ includes/polling/os/dell-ups.inc.php | 4 +- 4 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 includes/discovery/sensors/power/dell-ups.inc.php create mode 100644 includes/discovery/sensors/runtime/dell-ups.inc.php create mode 100644 includes/discovery/sensors/states/dell-ups.inc.php diff --git a/includes/discovery/sensors/power/dell-ups.inc.php b/includes/discovery/sensors/power/dell-ups.inc.php new file mode 100644 index 0000000000..ce4f55a9e9 --- /dev/null +++ b/includes/discovery/sensors/power/dell-ups.inc.php @@ -0,0 +1,21 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if ($device['os'] == 'dell-ups') { + echo 'Dell UPS: '; + $temp = snmp_get($device, "physicalOutputPresentConsumption.0", "-Ovqe", "DELL-SNMP-UPS-MIB"); + if (is_numeric($temp) && !is_null($temp)) { + $oid = '.1.3.6.1.4.1.674.10902.2.120.2.6.0'; + $descr = 'System Consumption'; + discover_sensor($valid['sensor'], 'power', $device, $oid, '0', 'dell-ups', $descr, '1', '1', null, null, null, null, $temp); + } +} diff --git a/includes/discovery/sensors/runtime/dell-ups.inc.php b/includes/discovery/sensors/runtime/dell-ups.inc.php new file mode 100644 index 0000000000..9d3d739c3a --- /dev/null +++ b/includes/discovery/sensors/runtime/dell-ups.inc.php @@ -0,0 +1,27 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if ($device['os'] == 'dell-ups') { + echo 'Dell UPS: '; + $temp = snmp_get($device, "physicalBatterySecondsRemaining.0", "-Ovqe", "DELL-SNMP-UPS-MIB"); + if (is_numeric($temp) && !is_null($temp)) { + $oid = '.1.3.6.1.4.1.674.10902.2.120.5.3.0'; + $descr = 'Runtime'; + $divisor = '60'; + $current = $temp / 60; + $low_limit = 5; + $low_limit_warn = 10; + $warn_limit = 2000; + $high_limit = 3000; + discover_sensor($valid['sensor'], 'runtime', $device, $oid, '0', 'dell-ups', $descr, $divisor, '1', $low_limit, $low_limit_warn, $warn_limit, $high_limit, $current); + } +} diff --git a/includes/discovery/sensors/states/dell-ups.inc.php b/includes/discovery/sensors/states/dell-ups.inc.php new file mode 100644 index 0000000000..57ef849a66 --- /dev/null +++ b/includes/discovery/sensors/states/dell-ups.inc.php @@ -0,0 +1,52 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if ($device['os'] == 'dell-ups') { + $temp = snmp_get($device, "productStatusGlobalStatus.0", "-Ovqe", "DELL-SNMP-UPS-MIB"); + $cur_oid = '.1.3.6.1.4.1.674.10902.2.110.1.0'; + $index = '0'; + + if (is_numeric($temp)) { + //Create State Index + $state_name = 'productStatusGlobalStatus'; + $state_index_id = create_state_index($state_name); + + //Create State Translation + if ($state_index_id !== null) { + $states = array( + array($state_index_id,'other',0,1,3) , + array($state_index_id,'unknown',0,2,3) , + array($state_index_id,'ok',0,3,0) , + array($state_index_id,'non-critical',0,4,1) , + array($state_index_id,'critical',0,5,2) , + array($state_index_id,'non-recoverable',0,6,2) + ); + foreach ($states as $value) { + $insert = array( + 'state_index_id' => $value[0], + 'state_descr' => $value[1], + 'state_draw_graph' => $value[2], + 'state_value' => $value[3], + 'state_generic_value' => $value[4] + ); + dbInsert($insert, 'state_translations'); + } + } + + $descr = 'Current Status'; + //Discover Sensors + discover_sensor($valid['sensor'], 'state', $device, $cur_oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $temp, 'snmp', $index); + + //Create Sensor To State Index + create_sensor_to_state_index($device, $state_name, $index); + } +} diff --git a/includes/polling/os/dell-ups.inc.php b/includes/polling/os/dell-ups.inc.php index fa0ca81a57..dac7591b73 100644 --- a/includes/polling/os/dell-ups.inc.php +++ b/includes/polling/os/dell-ups.inc.php @@ -10,8 +10,8 @@ * the source code distribution for details. */ -$data = snmp_get_multi($device, 'productIDDisplayName.0 productIDVendor.0 productIDVersion.0 physicalIdentSerialNumber.0', '-OQUs', 'DELL-SNMP-UPS-MIB'); +$data = snmp_get_multi($device, 'productIDDisplayName.0 productIDBuildNumber.0 productIDVersion.0 physicalIdentSerialNumber.0', '-OQUs', 'DELL-SNMP-UPS-MIB'); $hardware = $data[0]['productIDDisplayName']; $serial = $data[0]['physicalIdentSerialNumber']; -$version = $data[0]['productIDVersion'] . $data[0]['productIDVendor']; +$version = $data[0]['productIDVersion'] . '.' . $data[0]['productIDBuildNumber'];