newdevice: Added additional sensor support for Sentry4 devices (#7198)

This commit is contained in:
Neil Lathwood
2017-08-22 20:52:27 +01:00
committed by GitHub
parent e1ffdedb6b
commit 65c6240c2a
5 changed files with 148 additions and 2 deletions
@@ -0,0 +1,34 @@
<?php
/**
* sentry4.inc.php
*
* LibreNMS frequency discovery module for Sentry4
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2017 Neil Lathwood
* @author Neil Lathwood <[email protected]>
*/
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);
}
}
@@ -0,0 +1,37 @@
<?php
/**
* sentry4.inc.php
*
* LibreNMS humidity discovery module for Sentry4
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2017 Neil Lathwood
* @author Neil Lathwood <[email protected]>
*/
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);
}
}
@@ -0,0 +1,33 @@
<?php
/**
* sentry4.inc.php
*
* LibreNMS power discovery module for Sentry4
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2017 Neil Lathwood
* @author Neil Lathwood <[email protected]>
*/
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);
}
}
@@ -0,0 +1,42 @@
<?php
/**
* sentry4.inc.php
*
* LibreNMS pre-cache discovery module for Sentry4
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2017 Neil Lathwood
* @author Neil Lathwood <[email protected]>
*/
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');
@@ -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);
}
}