mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
feature: Implement dynamic temperature scale detection and value conversion for siteboss (#7734)
* added comments describing changes needed to be implemented * Added patch by laf to update the underlying function, modified OID value in yaml to poll string instead of integer * Second patch to discovery function peer laf/murrant
This commit is contained in:
committed by
Tony Murray
parent
3206447326
commit
3720f0e776
@@ -5,11 +5,11 @@ modules:
|
||||
data:
|
||||
-
|
||||
oid: esPointTable
|
||||
value: esPointValueInt
|
||||
num_oid: .1.3.6.1.4.1.3052.12.1.1.1.1.6.
|
||||
value: esPointValueStr
|
||||
num_oid: .1.3.6.1.4.1.3052.12.1.1.1.1.7.
|
||||
descr: esPointName
|
||||
skip_values:
|
||||
-
|
||||
oid: esIndexPC
|
||||
op: '!='
|
||||
value: 1
|
||||
value: 1
|
||||
|
@@ -980,11 +980,21 @@ function discovery_process(&$valid, $device, $sensor_type, $pre_cache)
|
||||
d_echo($raw_data);
|
||||
|
||||
foreach ($raw_data as $index => $snmp_data) {
|
||||
$user_function = null;
|
||||
if (isset($data['user_function'])) {
|
||||
$user_function = $data['user_function'];
|
||||
}
|
||||
// get the value for this sensor, check 'value' and 'oid', if state string, translate to a number
|
||||
$data_name = isset($data['value']) ? $data['value'] : $data['oid']; // fallback to oid if value is not set
|
||||
|
||||
$tmp_value = $snmp_data[$data_name];
|
||||
if (!is_numeric($tmp_value)) {
|
||||
if ($sensor_type === 'temperature') {
|
||||
// For temp sensors, try and detect fahrenheit values
|
||||
if (ends_with($tmp_value, 'f', true)) {
|
||||
$user_function = 'fahrenheit_to_celsius';
|
||||
}
|
||||
}
|
||||
preg_match('/-?\d*\.?\d+/', $tmp_value, $temp_response);
|
||||
if (!empty($temp_response[0])) {
|
||||
$tmp_value = $temp_response[0];
|
||||
@@ -1027,6 +1037,11 @@ function discovery_process(&$valid, $device, $sensor_type, $pre_cache)
|
||||
$high_limit = is_numeric($data['high_limit']) ? $data['high_limit'] : dynamic_discovery_get_value('high_limit', $index, $data, $pre_cache, 'null');
|
||||
|
||||
$sensor_name = $device['os'];
|
||||
|
||||
if (isset($user_function) && function_exists($user_function)) {
|
||||
$value = $user_function($value);
|
||||
}
|
||||
|
||||
if ($sensor_type === 'state') {
|
||||
$sensor_name = $data['state_name'] ?: $data['oid'];
|
||||
create_state_index($sensor_name, $data['states']);
|
||||
@@ -1040,7 +1055,7 @@ function discovery_process(&$valid, $device, $sensor_type, $pre_cache)
|
||||
}
|
||||
|
||||
$uindex = str_replace('{{ $index }}', $index, $data['index'] ?: $index);
|
||||
discover_sensor($valid['sensor'], $sensor_type, $device, $oid, $uindex, $sensor_name, $descr, $divisor, $multiplier, $low_limit, $low_warn_limit, $warn_limit, $high_limit, $value);
|
||||
discover_sensor($valid['sensor'], $sensor_type, $device, $oid, $uindex, $sensor_name, $descr, $divisor, $multiplier, $low_limit, $low_warn_limit, $warn_limit, $high_limit, $value, 'snmp', null, null, $user_function);
|
||||
|
||||
if ($sensor_type === 'state') {
|
||||
create_sensor_to_state_index($device, $sensor_name, $uindex);
|
||||
|
Reference in New Issue
Block a user