From acfc2e7c8105a23c2d1ce5a1311ae23d0c277ebe Mon Sep 17 00:00:00 2001 From: PipoCanaja <38363551+PipoCanaja@users.noreply.github.com> Date: Tue, 17 Dec 2019 09:08:12 +0100 Subject: [PATCH] Added Huawei UPS2000 support (#10831) * UPS2000 * tests * over * filter on sysDescr --- includes/definitions/huaweiups.yaml | 6 +- includes/discovery/functions.inc.php | 3 + includes/polling/os/huaweiups.inc.php | 21 ++ tests/data/huaweiups_ups2000.json | 386 ++++++++++++++++++++++++ tests/snmpsim/huaweiups_ups2000.snmprec | 56 ++++ 5 files changed, 471 insertions(+), 1 deletion(-) create mode 100644 includes/polling/os/huaweiups.inc.php create mode 100644 tests/data/huaweiups_ups2000.json create mode 100644 tests/snmpsim/huaweiups_ups2000.snmprec diff --git a/includes/definitions/huaweiups.yaml b/includes/definitions/huaweiups.yaml index 9a3bff4a9c..6679b47c56 100644 --- a/includes/definitions/huaweiups.yaml +++ b/includes/definitions/huaweiups.yaml @@ -6,9 +6,13 @@ icon: huawei rfc1628_compat: true over: - { graph: device_current, text: Current } + - { graph: device_voltage, text: Voltage } + - { graph: device_load, text: Load } discovery: - - sysDescr: Linux GSE200M + sysDescr: + - Linux GSE200M + - UPS snmpget: oid: UPS-MIB::upsIdentManufacturer.0 value: HUAWEI diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index 238df10dc0..1b7547ec9a 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -913,6 +913,9 @@ function get_device_divisor($device, $os_version, $sensor_type, $oid) } } elseif ($device['os'] == 'huaweiups') { if ($sensor_type == 'frequency') { + if (starts_with($device['hardware'], "UPS2000")) { + return 10; + } return 100; } } elseif ($device['os'] == 'hpe-rtups') { diff --git a/includes/polling/os/huaweiups.inc.php b/includes/polling/os/huaweiups.inc.php new file mode 100644 index 0000000000..2607b73fb5 --- /dev/null +++ b/includes/polling/os/huaweiups.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. + */ + +$oids = ['upsIdentModel.0', 'upsIdentUPSSoftwareVersion.0']; +$data = snmp_get_multi($device, $oids, '-OQUs', 'UPS-MIB'); + +if (!empty($data[0]['upsIdentModel'])) { + $hardware = $data[0]['upsIdentModel']; +} +if (!empty($data[0]['upsIdentUPSSoftwareVersion'])) { + $version = $data[0]['upsIdentUPSSoftwareVersion']; +} diff --git a/tests/data/huaweiups_ups2000.json b/tests/data/huaweiups_ups2000.json new file mode 100644 index 0000000000..ceb6928ccf --- /dev/null +++ b/tests/data/huaweiups_ups2000.json @@ -0,0 +1,386 @@ +{ + "os": { + "discovery": { + "devices": [ + { + "sysName": "", + "sysObjectID": ".1.3.6.1.4.1.2011.6.174.4.1.2.4", + "sysDescr": "SNMP Card for HUAWEI UPS2000", + "sysContact": null, + "version": null, + "hardware": null, + "features": null, + "os": "huaweiups", + "type": "power", + "serial": null, + "icon": "huawei.svg", + "location": null + } + ] + }, + "poller": { + "devices": [ + { + "sysName": "", + "sysObjectID": ".1.3.6.1.4.1.2011.6.174.4.1.2.4", + "sysDescr": "SNMP Card for HUAWEI UPS2000", + "sysContact": "", + "version": "V100R001C00SPC602", + "hardware": "UPS2000 6kVA", + "features": null, + "os": "huaweiups", + "type": "power", + "serial": null, + "icon": "huawei.svg", + "location": "" + } + ] + } + }, + "sensors": { + "discovery": { + "sensors": [ + { + "sensor_deleted": 0, + "sensor_class": "current", + "poller_type": "snmp", + "sensor_oid": ".1.3.6.1.2.1.33.1.4.4.1.3.1", + "sensor_index": "1", + "sensor_type": "rfc1628", + "sensor_descr": "Output", + "group": null, + "sensor_divisor": 10, + "sensor_multiplier": 1, + "sensor_current": 7.2, + "sensor_limit": null, + "sensor_limit_warn": null, + "sensor_limit_low": null, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_prev": null, + "user_func": null, + "state_name": null + }, + { + "sensor_deleted": 0, + "sensor_class": "current", + "poller_type": "snmp", + "sensor_oid": ".1.3.6.1.2.1.33.1.2.6.0", + "sensor_index": "500", + "sensor_type": "rfc1628", + "sensor_descr": "Battery", + "group": null, + "sensor_divisor": 10, + "sensor_multiplier": 1, + "sensor_current": 0.4, + "sensor_limit": null, + "sensor_limit_warn": null, + "sensor_limit_low": null, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_prev": null, + "user_func": null, + "state_name": null + }, + { + "sensor_deleted": 0, + "sensor_class": "frequency", + "poller_type": "snmp", + "sensor_oid": ".1.3.6.1.2.1.33.1.3.3.1.2.1", + "sensor_index": "3.2.0.1", + "sensor_type": "rfc1628", + "sensor_descr": "Input", + "group": null, + "sensor_divisor": 100, + "sensor_multiplier": 1, + "sensor_current": 5, + "sensor_limit": 5.25, + "sensor_limit_warn": null, + "sensor_limit_low": 4.75, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_prev": null, + "user_func": null, + "state_name": null + }, + { + "sensor_deleted": 0, + "sensor_class": "load", + "poller_type": "snmp", + "sensor_oid": ".1.3.6.1.2.1.33.1.4.4.1.5.1", + "sensor_index": "501", + "sensor_type": "rfc1628", + "sensor_descr": "Percentage load", + "group": null, + "sensor_divisor": 1, + "sensor_multiplier": 1, + "sensor_current": 27, + "sensor_limit": 80, + "sensor_limit_warn": null, + "sensor_limit_low": null, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_prev": null, + "user_func": null, + "state_name": null + }, + { + "sensor_deleted": 0, + "sensor_class": "power", + "poller_type": "snmp", + "sensor_oid": ".1.3.6.1.2.1.33.1.4.4.1.4.1", + "sensor_index": "301", + "sensor_type": "rfc1628", + "sensor_descr": "Output", + "group": null, + "sensor_divisor": 1, + "sensor_multiplier": 1, + "sensor_current": 1, + "sensor_limit": null, + "sensor_limit_warn": null, + "sensor_limit_low": null, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_prev": null, + "user_func": null, + "state_name": null + }, + { + "sensor_deleted": 0, + "sensor_class": "runtime", + "poller_type": "snmp", + "sensor_oid": ".1.3.6.1.2.1.33.1.2.2.0", + "sensor_index": "100", + "sensor_type": "rfc1628", + "sensor_descr": "Time on battery", + "group": null, + "sensor_divisor": 60, + "sensor_multiplier": 1, + "sensor_current": 0, + "sensor_limit": 2, + "sensor_limit_warn": 1, + "sensor_limit_low": 0, + "sensor_limit_low_warn": 0, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_prev": null, + "user_func": null, + "state_name": null + }, + { + "sensor_deleted": 0, + "sensor_class": "runtime", + "poller_type": "snmp", + "sensor_oid": ".1.3.6.1.2.1.33.1.2.3.0", + "sensor_index": "200", + "sensor_type": "rfc1628", + "sensor_descr": "Estimated battery time remaining", + "group": null, + "sensor_divisor": 1, + "sensor_multiplier": 1, + "sensor_current": 4294967295, + "sensor_limit": 10000, + "sensor_limit_warn": null, + "sensor_limit_low": 5, + "sensor_limit_low_warn": 10, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_prev": null, + "user_func": null, + "state_name": null + }, + { + "sensor_deleted": 0, + "sensor_class": "state", + "poller_type": "snmp", + "sensor_oid": ".1.3.6.1.2.1.33.1.4.1.0", + "sensor_index": "0", + "sensor_type": "upsOutputSourceState", + "sensor_descr": "Output Source", + "group": null, + "sensor_divisor": 1, + "sensor_multiplier": 1, + "sensor_current": 3, + "sensor_limit": null, + "sensor_limit_warn": null, + "sensor_limit_low": null, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": "0", + "entPhysicalIndex_measured": null, + "sensor_prev": null, + "user_func": null, + "state_name": "upsOutputSourceState" + }, + { + "sensor_deleted": 0, + "sensor_class": "temperature", + "poller_type": "snmp", + "sensor_oid": ".1.3.6.1.2.1.33.1.2.7.0", + "sensor_index": "0", + "sensor_type": "rfc1628", + "sensor_descr": "Battery", + "group": null, + "sensor_divisor": 1, + "sensor_multiplier": 1, + "sensor_current": 21, + "sensor_limit": 41, + "sensor_limit_warn": null, + "sensor_limit_low": 11, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_prev": null, + "user_func": null, + "state_name": null + }, + { + "sensor_deleted": 0, + "sensor_class": "voltage", + "poller_type": "snmp", + "sensor_oid": ".1.3.6.1.2.1.33.1.4.4.1.2.1", + "sensor_index": "1", + "sensor_type": "rfc1628", + "sensor_descr": "Output", + "group": null, + "sensor_divisor": 1, + "sensor_multiplier": 1, + "sensor_current": 230, + "sensor_limit": 264.5, + "sensor_limit_warn": null, + "sensor_limit_low": 195.5, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_prev": null, + "user_func": null, + "state_name": null + }, + { + "sensor_deleted": 0, + "sensor_class": "voltage", + "poller_type": "snmp", + "sensor_oid": ".1.3.6.1.2.1.33.1.3.3.1.3.1", + "sensor_index": "101", + "sensor_type": "rfc1628", + "sensor_descr": "Input", + "group": null, + "sensor_divisor": 1, + "sensor_multiplier": 1, + "sensor_current": 233, + "sensor_limit": 267.95, + "sensor_limit_warn": null, + "sensor_limit_low": 198.05, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_prev": null, + "user_func": null, + "state_name": null + }, + { + "sensor_deleted": 0, + "sensor_class": "voltage", + "poller_type": "snmp", + "sensor_oid": ".1.3.6.1.2.1.33.1.5.3.1.2.1", + "sensor_index": "201", + "sensor_type": "rfc1628", + "sensor_descr": "Bypass", + "group": null, + "sensor_divisor": 1, + "sensor_multiplier": 1, + "sensor_current": 233, + "sensor_limit": 267.95, + "sensor_limit_warn": null, + "sensor_limit_low": 198.05, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_prev": null, + "user_func": null, + "state_name": null + } + ], + "state_indexes": [ + { + "state_name": "upsOutputSourceState", + "state_descr": "Other", + "state_draw_graph": 0, + "state_value": 1, + "state_generic_value": 3 + }, + { + "state_name": "upsOutputSourceState", + "state_descr": "None", + "state_draw_graph": 0, + "state_value": 2, + "state_generic_value": 3 + }, + { + "state_name": "upsOutputSourceState", + "state_descr": "Normal", + "state_draw_graph": 0, + "state_value": 3, + "state_generic_value": 0 + }, + { + "state_name": "upsOutputSourceState", + "state_descr": "Bypass", + "state_draw_graph": 0, + "state_value": 4, + "state_generic_value": 2 + }, + { + "state_name": "upsOutputSourceState", + "state_descr": "Battery", + "state_draw_graph": 0, + "state_value": 5, + "state_generic_value": 2 + }, + { + "state_name": "upsOutputSourceState", + "state_descr": "Booster", + "state_draw_graph": 0, + "state_value": 6, + "state_generic_value": 2 + }, + { + "state_name": "upsOutputSourceState", + "state_descr": "Reducer", + "state_draw_graph": 0, + "state_value": 7, + "state_generic_value": 2 + } + ] + }, + "poller": "matches discovery" + } +} diff --git a/tests/snmpsim/huaweiups_ups2000.snmprec b/tests/snmpsim/huaweiups_ups2000.snmprec new file mode 100644 index 0000000000..999fc23015 --- /dev/null +++ b/tests/snmpsim/huaweiups_ups2000.snmprec @@ -0,0 +1,56 @@ +1.3.6.1.2.1.1.1.0|4|SNMP Card for HUAWEI UPS2000 +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.2011.6.174.4.1.2.4 +1.3.6.1.2.1.1.3.0|67|3239276937 +1.3.6.1.2.1.1.4.0|4| +1.3.6.1.2.1.1.5.0|4| +1.3.6.1.2.1.1.6.0|4| +1.3.6.1.2.1.11.1.0|65|11440 +1.3.6.1.2.1.11.2.0|65|11371 +1.3.6.1.2.1.11.3.0|65|0 +1.3.6.1.2.1.11.4.0|65|44 +1.3.6.1.2.1.11.5.0|65|0 +1.3.6.1.2.1.11.6.0|65|0 +1.3.6.1.2.1.11.8.0|65|0 +1.3.6.1.2.1.11.9.0|65|0 +1.3.6.1.2.1.11.10.0|65|0 +1.3.6.1.2.1.11.11.0|65|0 +1.3.6.1.2.1.11.12.0|65|0 +1.3.6.1.2.1.11.13.0|65|54971 +1.3.6.1.2.1.11.14.0|65|0 +1.3.6.1.2.1.11.15.0|65|7014 +1.3.6.1.2.1.11.16.0|65|63 +1.3.6.1.2.1.11.17.0|65|0 +1.3.6.1.2.1.11.18.0|65|0 +1.3.6.1.2.1.11.19.0|65|0 +1.3.6.1.2.1.11.20.0|65|0 +1.3.6.1.2.1.11.21.0|65|0 +1.3.6.1.2.1.11.22.0|65|0 +1.3.6.1.2.1.11.24.0|65|0 +1.3.6.1.2.1.11.25.0|65|0 +1.3.6.1.2.1.11.26.0|65|0 +1.3.6.1.2.1.11.27.0|65|0 +1.3.6.1.2.1.11.28.0|65|11373 +1.3.6.1.2.1.11.29.0|65|0 +1.3.6.1.2.1.11.30.0|2|2 +1.3.6.1.2.1.11.31.0|65|0 +1.3.6.1.2.1.11.32.0|65|0 +1.3.6.1.2.1.33.1.1.1.0|4|HUAWEI +1.3.6.1.2.1.33.1.1.2.0|4|UPS2000 6kVA +1.3.6.1.2.1.33.1.1.3.0|4|V100R001C00SPC602 +1.3.6.1.2.1.33.1.2.1.0|66|2 +1.3.6.1.2.1.33.1.2.2.0|66|0 +1.3.6.1.2.1.33.1.2.3.0|66|4294967295 +1.3.6.1.2.1.33.1.2.4.0|66|100 +1.3.6.1.2.1.33.1.2.5.0|66|2707 +1.3.6.1.2.1.33.1.2.6.0|2|4 +1.3.6.1.2.1.33.1.2.7.0|2|21 +1.3.6.1.2.1.33.1.3.3.1.2.1|2|500 +1.3.6.1.2.1.33.1.3.3.1.3.1|2|233 +1.3.6.1.2.1.33.1.4.1.0|2|3 +1.3.6.1.2.1.33.1.4.2.0|66|500 +1.3.6.1.2.1.33.1.4.4.1.2.1|2|230 +1.3.6.1.2.1.33.1.4.4.1.3.1|2|72 +1.3.6.1.2.1.33.1.4.4.1.4.1|2|1 +1.3.6.1.2.1.33.1.4.4.1.5.1|2|27 +1.3.6.1.2.1.33.1.5.1.0|66|500 +1.3.6.1.2.1.33.1.5.3.1.2.1|2|233