newdevice: Added further sensor support for Geist Watchdog (#7143)

* newdevice: Added further sensor support for Geist Watchdog

* relaxed if check
This commit is contained in:
Neil Lathwood
2017-08-19 20:22:23 +01:00
committed by GitHub
parent 31993387e4
commit 25d79ce9d7
9 changed files with 168 additions and 4 deletions

View File

@@ -1675,6 +1675,19 @@ function fahrenheit_to_celsius($scale, $value)
}
return sprintf('%.02f', $value);
}
/**
*
* Simply passes the fahrenheit value to fahrenheit_to_celsius()
*
* @param $value
* @return float
*/
function conv_fahrenheit($value)
{
return fahrenheit_to_celsius('fahrenheit', $value);
}
function uw_to_dbm($value)
{
return 10 * log10($value / 1000);

View File

@@ -0,0 +1,73 @@
mib: GEIST-V4-MIB
modules:
sensors:
temperature:
data:
-
oid: internalTable
value: internalTemp
num_oid: .1.3.6.1.4.1.21239.5.1.2.1.5.
descr: internalName
-
oid: tempSensorTable
value: tempSensorTemp
num_oid: .1.3.6.1.4.1.21239.5.1.4.1.5.
descr: tempSensorName
-
oid: airFlowSensorTable
value: airFlowSensorTemp
num_oid: .1.3.6.1.4.1.21239.5.1.5.1.5.
descr: airFlowSensorName
-
oid: dewPointSensorTable
value: dewPointSensorTemp
num_oid: .1.3.6.1.4.1.21239.5.1.6.1.5.
descr: dewPointSensorName
-
oid: t3hdSensorTable
value: t3hdSensorIntTemp
num_oid: .1.3.6.1.4.1.21239.5.1.8.1.6.
descr: t3hdSensorIntName
-
oid: thdSensorTable
value: thdSensorTemp
num_oid: .1.3.6.1.4.1.21239.5.1.9.1.5.
descr: thdSensorName
current:
data:
-
oid: rpmSensorTable
value: rpmSensorCurrent
num_oid: .1.3.6.1.4.1.21239.5.1.10.1.10.
descr: rpmSensorName
voltage:
data:
-
oid: rpmSensorTable
value: rpmSensorVoltage
num_oid: .1.3.6.1.4.1.21239.5.1.10.1.6.
descr: rpmSensorName
humidty:
data:
-
oid: thdSensorTable
value: thdSensorHumidity
num_oid: .1.3.6.1.4.1.21239.5.1.9.1.6.
descr: thdSensorName
-
oid: t3hdSensorTable
value: t3hdSensorIntHumidity
num_oid: .1.3.6.1.4.1.21239.5.1.8.1.7.
descr: t3hdSensorIntName
-
oid: internalTable
value: internalHumidity
num_oid: .1.3.6.1.4.1.21239.5.1.2.1.6.
descr: internalName
airflow:
data:
-
oid: airFlowSensorTable
value: airFlowSensorFlow
num_oid: .1.3.6.1.4.1.21239.5.1.5.1.6.
descr: airFlowSensorName

View File

@@ -26,4 +26,6 @@
$value = snmp_get($device, 'climateAirflow', '-Oqv', 'GEIST-MIB-V3');
$current_oid = '.1.3.6.1.4.1.21239.2.2.1.9.1';
$descr = 'Airflow';
discover_sensor($valid['sensor'], 'airflow', $device, $current_oid, 'climateAirflow', 'geist-watchdog', $descr, 1, 1, null, null, null, null, $value);
if (is_numeric($value)) {
discover_sensor($valid['sensor'], 'airflow', $device, $current_oid, 'climateAirflow', 'geist-watchdog', $descr, 1, 1, null, null, null, null, $value);
}

View File

@@ -23,14 +23,14 @@
* @author Neil Lathwood <gh+n@laf.io>
*/
$value = snmp_get($device, 'climateHumidity', '-Oqv', 'GEIST-MIB-V3');
$value = return_number(snmp_get($device, 'climateHumidity', '-Oqv', 'GEIST-MIB-V3'));
if ($value) {
$current_oid = '.1.3.6.1.4.1.21239.2.2.1.7.1';
$descr = 'Humidity';
discover_sensor($valid['sensor'], 'humidity', $device, $current_oid, 'climateHumidity', 'geist-watchdog', $descr, 1, 1, null, null, null, null, $value);
}
$value = snmp_get($device, 'internalHumidity.1', '-Oqv', 'GEIST-V4-MIB');
$value = return_number(snmp_get($device, 'internalHumidity.1', '-Oqv', 'GEIST-V4-MIB'));
if ($value) {
$current_oid = '.1.3.6.1.4.1.21239.5.1.2.1.6.1';
$descr = 'Internal humidity';

View File

@@ -30,6 +30,13 @@ if ($value) {
discover_sensor($valid['sensor'], 'temperature', $device, $current_oid, 'climateTempC', 'geist-watchdog', $descr, 1, 1, null, null, null, null, $value);
}
$value = snmp_get($device, 'climateTempF', '-Oqv', 'GEIST-MIB-V3');
if ($value) {
$current_oid = '.1.3.6.1.4.1.21239.2.2.1.6.1';
$descr = 'Temperature';
discover_sensor($valid['sensor'], 'temperature', $device, $current_oid, 'climateTempF', 'geist-watchdog', $descr, 1, 1, null, null, null, null, $value, null, null, null, 'conv_fahrenheit');
}
$value = snmp_get($device, 'internalTemp.1', '-Oqv', 'GEIST-V4-MIB');
if ($value) {
$current_oid = '.1.3.6.1.4.1.21239.5.1.2.1.5.1';

View File

@@ -26,4 +26,6 @@
$value = snmp_get($device, 'climateVolts', '-Oqv', 'GEIST-MIB-V3');
$current_oid = '.1.3.6.1.4.1.21239.2.2.1.14.1';
$descr = 'Voltage';
discover_sensor($valid['sensor'], 'voltage', $device, $current_oid, 'climateVolts', 'geist-watchdog', $descr, 1, 1, null, null, null, null, $value);
if (is_numeric($value)) {
discover_sensor($valid['sensor'], 'voltage', $device, $current_oid, 'climateVolts', 'geist-watchdog', $descr, 1, 1, null, null, null, null, $value);
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* geist-watchdog.inc.php
*
* LibreNMS pre-cache poller module for Geist Watchdog
*
* 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 <gh+n@laf.io>
*/
$sensor_config['geist_temp_unit'] = snmp_get($device, 'temperatureUnits.0', '-Oqv', 'GEIST-V4-MIB');

View File

@@ -0,0 +1,28 @@
<?php
/**
* geist-watchdog.inc.php
*
* LibreNMS temperature poller module for Geist Watchdog
*
* 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 <gh+n@laf.io>
*/
if ($sensor_config['geist_temp_unit'] == 0) {
$sensor_value = conv_fahrenheit($sensor_value);
}

View File

@@ -1416,3 +1416,16 @@ function apc_relay_state($state)
break;
}
}
/**
* @param $value
* @return mixed
*/
function return_number($value)
{
preg_match('/[\d\.\-]+/', $value, $temp_response);
if (!empty($temp_response[0])) {
$value = $temp_response[0];
}
return $value;
}