From e223ec3ff2fbd867b07a3b057f10d3471465ddee Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Wed, 17 May 2017 05:39:35 +0100 Subject: [PATCH] newdevice: Added support for Geist PDU (#6646) --- includes/definitions/geist-pdu.yaml | 15 ++++++ includes/definitions/geist-watchdog.yaml | 8 ++- .../sensors/current/geist-pdu.inc.php | 53 +++++++++++++++++++ .../discovery/sensors/power/geist-pdu.inc.php | 50 +++++++++++++++++ .../sensors/pre-cache/geist-pdu.inc.php | 27 ++++++++++ .../sensors/voltage/geist-pdu.inc.php | 50 +++++++++++++++++ includes/polling/os/geist-pdu.inc.php | 27 ++++++++++ includes/polling/os/geist-watchdog.inc.php | 3 +- tests/snmpsim/geist-pdu.snmprec | 2 + 9 files changed, 232 insertions(+), 3 deletions(-) create mode 100644 includes/definitions/geist-pdu.yaml create mode 100644 includes/discovery/sensors/current/geist-pdu.inc.php create mode 100644 includes/discovery/sensors/power/geist-pdu.inc.php create mode 100644 includes/discovery/sensors/pre-cache/geist-pdu.inc.php create mode 100644 includes/discovery/sensors/voltage/geist-pdu.inc.php create mode 100644 includes/polling/os/geist-pdu.inc.php create mode 100644 tests/snmpsim/geist-pdu.snmprec diff --git a/includes/definitions/geist-pdu.yaml b/includes/definitions/geist-pdu.yaml new file mode 100644 index 0000000000..9a1a69e7a0 --- /dev/null +++ b/includes/definitions/geist-pdu.yaml @@ -0,0 +1,15 @@ +os: geist-pdu +text: 'Geist PDU' +type: power +icon: geist +group: geist +discovery: + - + sysObjectId: + - .1.3.6.1.4.1.21239.2 + sysDescr: + - RCM-O +mib_dir: + - geist +over: + - { graph: device_bits, text: 'Device Traffic' } diff --git a/includes/definitions/geist-watchdog.yaml b/includes/definitions/geist-watchdog.yaml index adc68fd358..ff24c7d236 100644 --- a/includes/definitions/geist-watchdog.yaml +++ b/includes/definitions/geist-watchdog.yaml @@ -2,9 +2,13 @@ os: geist-watchdog text: 'Geist Watchdog' type: environment icon: geist +group: geist discovery: - - sysObjectId: - - .1.3.6.1.4.1.21239. + - + sysObjectId: + - .1.3.6.1.4.1.21239. + sysDescr_except: + - RCM-O mib_dir: - geist over: diff --git a/includes/discovery/sensors/current/geist-pdu.inc.php b/includes/discovery/sensors/current/geist-pdu.inc.php new file mode 100644 index 0000000000..d5595dd83e --- /dev/null +++ b/includes/discovery/sensors/current/geist-pdu.inc.php @@ -0,0 +1,53 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2017 Neil Lathwood + * @author Neil Lathwood + */ + +foreach ($pre_cache['geist_pdu_iec'] as $index => $data) { + $divisor = 10; + $value = $data['ctrl3ChIECDeciAmpsA'] / $divisor; + $current_oid = '.1.3.6.1.4.1.21239.2.25.1.8.'; + $descr = $data['ctrl3ChIECName'] . ' Phase A'; + $oid = $current_oid . $index; + if ($value > 0) { + discover_sensor($valid['sensor'], 'current', $device, $oid, 'ctrl3ChIECDeciAmpsA', 'geist-pdu', $descr, $divisor, 1, null, null, null, null, $value); + } + + $divisor = 10; + $value = $data['ctrl3ChIECDeciAmpsB'] / $divisor; + $current_oid = '.1.3.6.1.4.1.21239.2.25.1.16.'; + $descr = $data['ctrl3ChIECName'] . ' Phase B'; + $oid = $current_oid . $index; + if ($value > 0) { + discover_sensor($valid['sensor'], 'current', $device, $oid, 'ctrl3ChIECDeciAmpsB', 'geist-pdu', $descr, $divisor, 1, null, null, null, null, $value); + } + + $divisor = 10; + $value = $data['ctrl3ChIECDeciAmpsC'] / $divisor; + $current_oid = '.1.3.6.1.4.1.21239.2.25.1.24.'; + $descr = $data['ctrl3ChIECName'] . ' Phase C'; + $oid = $current_oid . $index; + if ($value > 0) { + discover_sensor($valid['sensor'], 'current', $device, $oid, 'ctrl3ChIECDeciAmpsC', 'geist-pdu', $descr, $divisor, 1, null, null, null, null, $value); + } +} diff --git a/includes/discovery/sensors/power/geist-pdu.inc.php b/includes/discovery/sensors/power/geist-pdu.inc.php new file mode 100644 index 0000000000..0dd6798568 --- /dev/null +++ b/includes/discovery/sensors/power/geist-pdu.inc.php @@ -0,0 +1,50 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2017 Neil Lathwood + * @author Neil Lathwood + */ + +foreach ($pre_cache['geist_pdu_iec'] as $index => $data) { + $value = $data['ctrl3ChIECRealPowerA'] / $divisor; + $current_oid = '.1.3.6.1.4.1.21239.2.25.1.10.'; + $descr = $data['ctrl3ChIECName'] . ' Phase A'; + $oid = $current_oid . $index; + if ($value > 0) { + discover_sensor($valid['sensor'], 'power', $device, $oid, 'ctrl3ChIECRealPowerA', 'geist-pdu', $descr, 1, 1, null, null, null, null, $value); + } + + $value = $data['ctrl3ChIECRealPowerB'] / $divisor; + $current_oid = '.1.3.6.1.4.1.21239.2.25.1.18.'; + $descr = $data['ctrl3ChIECName'] . ' Phase B'; + $oid = $current_oid . $index; + if ($value > 0) { + discover_sensor($valid['sensor'], 'power', $device, $oid, 'ctrl3ChIECRealPowerB', 'geist-pdu', $descr, 1, 1, null, null, null, null, $value); + } + + $value = $data['ctrl3ChIECRealPowerC'] / $divisor; + $current_oid = '.1.3.6.1.4.1.21239.2.25.1.26.'; + $descr = $data['ctrl3ChIECName'] . ' Phase C'; + $oid = $current_oid . $index; + if ($value > 0) { + discover_sensor($valid['sensor'], 'power', $device, $oid, 'ctrl3ChIECRealPowerC', 'geist-pdu', $descr, 1, 1, null, null, null, null, $value); + } +} diff --git a/includes/discovery/sensors/pre-cache/geist-pdu.inc.php b/includes/discovery/sensors/pre-cache/geist-pdu.inc.php new file mode 100644 index 0000000000..3e2eb9a52b --- /dev/null +++ b/includes/discovery/sensors/pre-cache/geist-pdu.inc.php @@ -0,0 +1,27 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2017 Neil Lathwood + * @author Neil Lathwood + */ + +echo 'ctrl3ChIECTable '; +$pre_cache['geist_pdu_iec'] = snmpwalk_cache_oid($device, 'ctrl3ChIECTable', array(), 'GEIST-MIB-V3'); diff --git a/includes/discovery/sensors/voltage/geist-pdu.inc.php b/includes/discovery/sensors/voltage/geist-pdu.inc.php new file mode 100644 index 0000000000..11c58effdd --- /dev/null +++ b/includes/discovery/sensors/voltage/geist-pdu.inc.php @@ -0,0 +1,50 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2017 Neil Lathwood + * @author Neil Lathwood + */ + +foreach ($pre_cache['geist_pdu_iec'] as $index => $data) { + $value = $data['ctrl3ChIECVoltsA']; + $current_oid = '.1.3.6.1.4.1.21239.2.25.1.6.'; + $descr = $data['ctrl3ChIECName'] . ' Phase A'; + $oid = $current_oid . $index; + if ($value > 0) { + discover_sensor($valid['sensor'], 'voltage', $device, $oid, 'ctrl3ChIECVoltsA', 'geist-pdu', $descr, 1, 1, null, null, null, null, $value); + } + + $value = $data['ctrl3ChIECVoltsB']; + $current_oid = '.1.3.6.1.4.1.21239.2.25.1.14.'; + $descr = $data['ctrl3ChIECName'] . ' Phase B'; + $oid = $current_oid . $index; + if ($value > 0) { + discover_sensor($valid['sensor'], 'voltage', $device, $oid, 'ctrl3ChIECVoltsB', 'geist-pdu', $descr, 1, 1, null, null, null, null, $value); + } + + $value = $data['ctrl3ChIECVoltsC']; + $current_oid = '.1.3.6.1.4.1.21239.2.25.1.22.'; + $descr = $data['ctrl3ChIECName'] . ' Phase C'; + $oid = $current_oid . $index; + if ($value > 0) { + discover_sensor($valid['sensor'], 'voltage', $device, $oid, 'ctrl3ChIECVoltsC', 'geist-pdu', $descr, 1, 1, null, null, null, null, $value); + } +} diff --git a/includes/polling/os/geist-pdu.inc.php b/includes/polling/os/geist-pdu.inc.php new file mode 100644 index 0000000000..5923026167 --- /dev/null +++ b/includes/polling/os/geist-pdu.inc.php @@ -0,0 +1,27 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2017 Neil Lathwood + * @author Neil Lathwood + */ + +$version = snmp_get($device, 'productVersion.0', '-Oqv', 'GEIST-MIB-V3'); +$hardware = snmp_get($device, 'productHardware.0', '-Oqv', 'GEIST-MIB-V3'); diff --git a/includes/polling/os/geist-watchdog.inc.php b/includes/polling/os/geist-watchdog.inc.php index f2275c45df..09e2bfe027 100644 --- a/includes/polling/os/geist-watchdog.inc.php +++ b/includes/polling/os/geist-watchdog.inc.php @@ -23,4 +23,5 @@ * @author Neil Lathwood */ -$serial = snmp_get($device, 'climateSerial', '-Oqv', 'GEIST-MIB-V3'); +$serial = snmp_get($device, 'climateSerial', '-Oqv', 'GEIST-MIB-V3'); +$version = snmp_get($device, 'productVersion.0', '-Oqv', 'GEIST-MIB-V3'); diff --git a/tests/snmpsim/geist-pdu.snmprec b/tests/snmpsim/geist-pdu.snmprec new file mode 100644 index 0000000000..0d93f2f354 --- /dev/null +++ b/tests/snmpsim/geist-pdu.snmprec @@ -0,0 +1,2 @@ +1.3.6.1.2.1.1.1.0|4|RCM-O +1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.21239.2 \ No newline at end of file