mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
fix: issues with Geist Watchdog
miss-named variable in sensor pre-caching internal humidity and temperature was discovered twice humidity was mis-spelled in yaml discovery temperature and current had incorrect divisor in yaml remove redundant fahrenheit to celsius function fixes #7236
This commit is contained in:
@@ -1664,11 +1664,14 @@ function update_os_cache($force = false)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $scale
|
||||
* @param $value
|
||||
* @return float
|
||||
* Converts fahrenheit to celsius (with 2 decimal places)
|
||||
* if $scale is not fahrenheit, it assumes celsius and returns the value
|
||||
*
|
||||
* @param float $value
|
||||
* @param string $scale fahrenheit or celsius
|
||||
* @return string (containing a float)
|
||||
*/
|
||||
function fahrenheit_to_celsius($scale, $value)
|
||||
function fahrenheit_to_celsius($value, $scale = 'fahrenheit')
|
||||
{
|
||||
if ($scale === 'fahrenheit') {
|
||||
$value = ($value - 32) / 1.8;
|
||||
@@ -1676,18 +1679,6 @@ 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);
|
||||
|
@@ -2,6 +2,8 @@ mib: GEIST-V4-MIB
|
||||
modules:
|
||||
sensors:
|
||||
temperature:
|
||||
options:
|
||||
divisor: 10
|
||||
data:
|
||||
-
|
||||
oid: internalTable
|
||||
@@ -40,6 +42,7 @@ modules:
|
||||
value: rpmSensorCurrent
|
||||
num_oid: .1.3.6.1.4.1.21239.5.1.10.1.10.
|
||||
descr: rpmSensorName
|
||||
divisor: 10
|
||||
voltage:
|
||||
data:
|
||||
-
|
||||
@@ -47,7 +50,7 @@ modules:
|
||||
value: rpmSensorVoltage
|
||||
num_oid: .1.3.6.1.4.1.21239.5.1.10.1.6.
|
||||
descr: rpmSensorName
|
||||
humidty:
|
||||
humidity:
|
||||
data:
|
||||
-
|
||||
oid: thdSensorTable
|
||||
@@ -70,4 +73,4 @@ modules:
|
||||
oid: airFlowSensorTable
|
||||
value: airFlowSensorFlow
|
||||
num_oid: .1.3.6.1.4.1.21239.5.1.5.1.6.
|
||||
descr: airFlowSensorName
|
||||
descr: airFlowSensorName
|
||||
|
@@ -29,10 +29,3 @@ if ($value) {
|
||||
$descr = 'Humidity';
|
||||
discover_sensor($valid['sensor'], 'humidity', $device, $current_oid, 'climateHumidity', 'geist-watchdog', $descr, 1, 1, null, null, null, null, $value);
|
||||
}
|
||||
|
||||
$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';
|
||||
discover_sensor($valid['sensor'], 'humidity', $device, $current_oid, 'internalHumidity.1', 'geist-watchdog', $descr, 1, 1, null, null, null, null, $value);
|
||||
}
|
||||
|
@@ -28,11 +28,11 @@ foreach ($pre_cache['emu2_temp'] as $id => $temp) {
|
||||
$index = $temp['emsProbeStatusProbeIndex'];
|
||||
$oid = '.1.3.6.1.4.1.318.1.1.10.3.13.1.1.3.' . $index;
|
||||
$descr = $temp['emsProbeStatusProbeName'];
|
||||
$low_limit = fahrenheit_to_celsius($pre_cache['emu2_temp_scale'], $temp['emsProbeStatusProbeMinTempThresh']);
|
||||
$low_warn_limit = fahrenheit_to_celsius($pre_cache['emu2_temp_scale'], $temp['emsProbeStatusProbeLowTempThresh']);
|
||||
$high_limit = fahrenheit_to_celsius($pre_cache['emu2_temp_scale'], $temp['emsProbeStatusProbeMaxTempThresh']);
|
||||
$high_warn_limit = fahrenheit_to_celsius($pre_cache['emu2_temp_scale'], $temp['emsProbeStatusProbeHighTempThresh']);
|
||||
$current = fahrenheit_to_celsius($pre_cache['emu2_temp_scale'], $temp['emsProbeStatusProbeTemperature']);
|
||||
$low_limit = fahrenheit_to_celsius($temp['emsProbeStatusProbeMinTempThresh'], $pre_cache['emu2_temp_scale']);
|
||||
$low_warn_limit = fahrenheit_to_celsius($temp['emsProbeStatusProbeLowTempThresh'], $pre_cache['emu2_temp_scale']);
|
||||
$high_limit = fahrenheit_to_celsius($temp['emsProbeStatusProbeMaxTempThresh'], $pre_cache['emu2_temp_scale']);
|
||||
$high_warn_limit = fahrenheit_to_celsius($temp['emsProbeStatusProbeHighTempThresh'], $pre_cache['emu2_temp_scale']);
|
||||
$current = fahrenheit_to_celsius($temp['emsProbeStatusProbeTemperature'], $pre_cache['emu2_temp_scale']);
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'aos-emu2', $descr, '1', '1', $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current);
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ foreach ($pre_cache['ethernetprobe2_sensorProbeTempTable'] as $index => $data) {
|
||||
$oid = '.1.3.6.1.4.1.3854.1.2.2.1.16.1.14.' . $index;
|
||||
$descr = $data['sensorProbeTempDescription'];
|
||||
$divisor = 10;
|
||||
$value = (fahrenheit_to_celsius($data['sensorProbeTempDegreeType'], $data['sensorProbeTempDegreeRaw']) / $divisor);
|
||||
$value = (fahrenheit_to_celsius($data['sensorProbeTempDegreeRaw'], $data['sensorProbeTempDegreeType']) / $divisor);
|
||||
$low_limit = $data['sensorProbeTempLowCritical'];
|
||||
$low_warn_limit = $data['sensorProbeTempLowWarning'];
|
||||
$warn_limit = $data['sensorProbeTempHighWarning'];
|
||||
|
@@ -34,16 +34,7 @@ $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';
|
||||
$descr = 'Internal temperature';
|
||||
$divisor = 10;
|
||||
$value = $value / $divisor;
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $current_oid, 'internalTemp.1', 'geist-watchdog', $descr, $divisor, 1, null, null, null, null, $value);
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $current_oid, 'climateTempF', 'geist-watchdog', $descr, 1, 1, null, null, null, null, $value, null, null, null, 'fahrenheit_to_celsius');
|
||||
}
|
||||
|
||||
$temp_table = snmpwalk_cache_oid($device, 'tempSensorTable', array(), 'GEIST-MIB-V3');
|
||||
|
@@ -20,15 +20,16 @@ function bulk_sensor_snmpget($device, $sensors)
|
||||
|
||||
/**
|
||||
* @param $device
|
||||
* @param string $type type/class of sensor
|
||||
* @return array
|
||||
*/
|
||||
function sensor_precache($device)
|
||||
function sensor_precache($device, $type)
|
||||
{
|
||||
$sensor_config = array();
|
||||
$sensor_cache = array();
|
||||
if (file_exists('includes/polling/sensors/pre-cache/'. $device['os'] .'.inc.php')) {
|
||||
include 'includes/polling/sensors/pre-cache/'. $device['os'] .'.inc.php';
|
||||
}
|
||||
return $sensor_config;
|
||||
return $sensor_cache;
|
||||
}
|
||||
|
||||
function poll_sensor($device, $class)
|
||||
@@ -51,7 +52,7 @@ function poll_sensor($device, $class)
|
||||
|
||||
$snmp_data = bulk_sensor_snmpget($device, $sensors);
|
||||
|
||||
$sensor_cache = sensor_precache($device);
|
||||
$sensor_cache = sensor_precache($device, $class);
|
||||
|
||||
foreach ($sensors as $sensor) {
|
||||
echo 'Checking (' . $sensor['poller_type'] . ") $class " . $sensor['sensor_descr'] . '... '.PHP_EOL;
|
||||
|
@@ -23,4 +23,6 @@
|
||||
* @author Neil Lathwood <neil@lathwood.co.uk>
|
||||
*/
|
||||
|
||||
$sensor_config['scale'] = snmp_get($device, 'emsStatusSysTempUnits.0', '-OQv', 'PowerNet-MIB');
|
||||
if ($type == 'temperature') {
|
||||
$sensor_cache['scale'] = snmp_get($device, 'emsStatusSysTempUnits.0', '-OQv', 'PowerNet-MIB');
|
||||
}
|
||||
|
@@ -23,4 +23,6 @@
|
||||
* @author Neil Lathwood <gh+n@laf.io>
|
||||
*/
|
||||
|
||||
$sensor_config['geist_temp_unit'] = snmp_get($device, 'temperatureUnits.0', '-Oqv', 'GEIST-V4-MIB');
|
||||
if ($type == 'temperature') {
|
||||
$sensor_cache['geist_temp_unit'] = snmp_get($device, 'temperatureUnits.0', '-Oqv', 'GEIST-V4-MIB');
|
||||
}
|
||||
|
@@ -23,4 +23,4 @@
|
||||
* @author Neil Lathwood <neil@lathwood.co.uk>
|
||||
*/
|
||||
|
||||
$sensor_value = fahrenheit_to_celsius($sensor_cache['scale'], $sensor_value);
|
||||
$sensor_value = fahrenheit_to_celsius($sensor_value, $sensor_cache['scale']);
|
||||
|
@@ -24,5 +24,5 @@
|
||||
*/
|
||||
|
||||
$temp_type = snmp_get($device, '.1.3.6.1.4.1.3854.1.2.2.1.16.1.12.' . $sensor['sensor_index'], '-Oqv', 'SPAGENT-MIB');
|
||||
$sensor_value = fahrenheit_to_celsius($temp_type, $sensor_value);
|
||||
$sensor_value = fahrenheit_to_celsius($sensor_value, $temp_type);
|
||||
unset($temp_type);
|
||||
|
@@ -23,6 +23,6 @@
|
||||
* @author Neil Lathwood <gh+n@laf.io>
|
||||
*/
|
||||
|
||||
if ($sensor_config['geist_temp_unit'] == 0) {
|
||||
$sensor_value = conv_fahrenheit($sensor_value);
|
||||
if ($sensor_cache['geist_temp_unit'] === '0') {
|
||||
$sensor_value = fahrenheit_to_celsius($sensor_value);
|
||||
}
|
||||
|
Reference in New Issue
Block a user