mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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:
@@ -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);
|
||||
|
73
includes/definitions/discovery/geist-watchdog.yaml
Normal file
73
includes/definitions/discovery/geist-watchdog.yaml
Normal 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
|
@@ -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);
|
||||
}
|
||||
|
@@ -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';
|
||||
|
@@ -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';
|
||||
|
@@ -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);
|
||||
}
|
||||
|
26
includes/polling/sensors/pre-cache/geist-watchdog.inc.php
Normal file
26
includes/polling/sensors/pre-cache/geist-watchdog.inc.php
Normal 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');
|
28
includes/polling/sensors/temperature/geist-watchdog.inc.php
Normal file
28
includes/polling/sensors/temperature/geist-watchdog.inc.php
Normal 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);
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user