From 65c6240c2aa4bd69a7f188b96cc7987dd1bfa2b6 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Tue, 22 Aug 2017 20:52:27 +0100 Subject: [PATCH] newdevice: Added additional sensor support for Sentry4 devices (#7198) --- .../sensors/frequency/sentry4.inc.php | 34 +++++++++++++++ .../sensors/humidity/sentry4.inc.php | 37 ++++++++++++++++ .../discovery/sensors/power/sentry4.inc.php | 33 +++++++++++++++ .../sensors/pre-cache/sentry4.inc.php | 42 +++++++++++++++++++ .../sensors/temperature/sentry4.inc.php | 4 +- 5 files changed, 148 insertions(+), 2 deletions(-) create mode 100644 includes/discovery/sensors/frequency/sentry4.inc.php create mode 100644 includes/discovery/sensors/humidity/sentry4.inc.php create mode 100644 includes/discovery/sensors/power/sentry4.inc.php create mode 100644 includes/discovery/sensors/pre-cache/sentry4.inc.php diff --git a/includes/discovery/sensors/frequency/sentry4.inc.php b/includes/discovery/sensors/frequency/sentry4.inc.php new file mode 100644 index 0000000000..cbb4e45c3b --- /dev/null +++ b/includes/discovery/sensors/frequency/sentry4.inc.php @@ -0,0 +1,34 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2017 Neil Lathwood + * @author Neil Lathwood + */ + +foreach ($pre_cache['sentry4_input'] as $index => $data) { + $descr = $data['st4InputCordName']; + $oid = ".1.3.6.1.4.1.1718.4.1.3.3.1.11.$index"; + $current = $data['st4InputCordFrequency']; + $divisor = 10; + if ($current >= 0) { + discover_sensor($valid['sensor'], 'frequency', $device, $oid, "st4InputCord.$index", 'sentry4', $descr, $divisor, 1, null, null, null, null, $current); + } +} diff --git a/includes/discovery/sensors/humidity/sentry4.inc.php b/includes/discovery/sensors/humidity/sentry4.inc.php new file mode 100644 index 0000000000..b68b98260a --- /dev/null +++ b/includes/discovery/sensors/humidity/sentry4.inc.php @@ -0,0 +1,37 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2017 Neil Lathwood + * @author Neil Lathwood + */ + +foreach ($pre_cache['sentry4_humid'] as $index => $data) { + $descr = $data['st4HumidSensorName']; + $oid = ".1.3.6.1.4.1.1718.4.1.10.3.1.1.$index"; + $low_limit = $data['st4HumidSensorLowAlarm']; + $low_warn_limit = $data['st4HumidSensorLowWarning']; + $high_limit = $data['st4HumidSensorHighAlarm']; + $high_warn_limit = $data['st4HumidSensorHighWarning']; + $current = $data['st4HumidSensorValue']; + if ($current >= 0) { + discover_sensor($valid['sensor'], 'humidity', $device, $oid, "st4HumidSensor.$index", 'sentry4', $descr, 1, 1, $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current); + } +} diff --git a/includes/discovery/sensors/power/sentry4.inc.php b/includes/discovery/sensors/power/sentry4.inc.php new file mode 100644 index 0000000000..5d76788d88 --- /dev/null +++ b/includes/discovery/sensors/power/sentry4.inc.php @@ -0,0 +1,33 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2017 Neil Lathwood + * @author Neil Lathwood + */ + +foreach ($pre_cache['sentry4_input'] as $index => $data) { + $descr = $data['st4InputCordName']; + $oid = ".1.3.6.1.4.1.1718.4.1.3.3.1.3.$index"; + $current = $data['st4InputCordActivePower']; + if ($current >= 0) { + discover_sensor($valid['sensor'], 'power', $device, $oid, "st4InputCord.$index", 'sentry4', $descr, 1, 1, null, null, null, null, $current); + } +} diff --git a/includes/discovery/sensors/pre-cache/sentry4.inc.php b/includes/discovery/sensors/pre-cache/sentry4.inc.php new file mode 100644 index 0000000000..b09d3ccae2 --- /dev/null +++ b/includes/discovery/sensors/pre-cache/sentry4.inc.php @@ -0,0 +1,42 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2017 Neil Lathwood + * @author Neil Lathwood + */ + +echo 'st4HumidSensorConfigTable '; +$pre_cache['sentry4_humid'] = snmpwalk_cache_oid($device, 'st4HumidSensorConfigTable', array(), 'Sentry4-MIB'); + +echo 'st4HumidSensorMonitorTable '; +$pre_cache['sentry4_humid'] = snmpwalk_cache_oid($device, 'st4HumidSensorMonitorTable', $pre_cache['sentry4_humid'], 'Sentry4-MIB'); + +echo 'st4TempSensorEventConfigTable '; +$pre_cache['sentry4_humid'] = snmpwalk_cache_oid($device, 'st4TempSensorEventConfigTable', $pre_cache['sentry4_humid'], 'Sentry4-MIB'); + +echo 'st4InputCordConfigTable '; +$pre_cache['sentry4_input'] = snmpwalk_cache_oid($device, 'st4InputCordConfigTable', array(), 'Sentry4-MIB'); + +echo 'st4InputCordMonitorTable '; +$pre_cache['sentry4_input'] = snmpwalk_cache_oid($device, 'st4InputCordMonitorTable', $pre_cache['sentry4_input'], 'Sentry4-MIB'); + +echo 'st4InputCordEventConfigTable '; +$pre_cache['sentry4_input'] = snmpwalk_cache_oid($device, 'st4InputCordEventConfigTable', $pre_cache['sentry4_input'], 'Sentry4-MIB'); diff --git a/includes/discovery/sensors/temperature/sentry4.inc.php b/includes/discovery/sensors/temperature/sentry4.inc.php index 086a4891d4..a2639152aa 100644 --- a/includes/discovery/sensors/temperature/sentry4.inc.php +++ b/includes/discovery/sensors/temperature/sentry4.inc.php @@ -39,9 +39,9 @@ foreach (explode("\n", $oids) as $data) { $low_limit = (snmp_get($device, "st4TempSensorLowAlarm.1.$index", '-Ovq', 'Sentry4-MIB') / $divisor); $high_warn_limit = (snmp_get($device, "st4TempSensorHighWarning.1.$index", '-Ovq', 'Sentry4-MIB') / $divisor); $high_limit = (snmp_get($device, "st4TempSensorHighAlarm.1.$index", '-Ovq', 'Sentry4-MIB') / $divisor); - $current = (snmp_get($device, "$temperature_oid", '-Ovq', 'Sentry4-MIB') / $divisor); + $current = (snmp_get($device, "$temperature_oid", '-OvqU', 'Sentry4-MIB') / $divisor); - if ($current >= 0) { + if (is_numeric($current) && $current >= 0) { discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $index, 'sentry4', $descr, $divisor, $multiplier, $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current); } }