feature: Added support for entity values in sensors (#7805)

* Added info on using OIDs in skip_values for sensors

* added more docs + entity support

* remove whitespace
This commit is contained in:
Neil Lathwood
2017-12-02 22:56:57 +00:00
committed by GitHub
parent f1fa61758b
commit 5357dd9515
2 changed files with 20 additions and 4 deletions

View File

@@ -75,18 +75,31 @@ The only sensor we have defined here is airflow. The available options are as fo
- `high_limit` (optional): This is the critical high threshold that `value` should be (used in alerting).
- `descr` (required): The visible label for this sensor. It can be a key with in the table or a static string, optionally using `{{ index }}`
- `index` (optional): This is the index value we use to uniquely identify this sensor. `{{ $index }}` will be replaced by the `index` from the snmp walk.
- `skip_values` (optional): This is an array of values we should skip over.
- `skip_values` (optional): This is an array of values we should skip over (see note below).
- `skip_value_lt` (optional): If sensor value is less than this, skip the discovery.
- `skip_value_gt` (optional): If sensor value is greater than this, skip the discovery.
- `entPhysicalIndex` (optional): If the sensor belongs to a physical entity then you can specify the index here.
- `entPhysicalIndex_measured` (optional): If the sensor belongs to a physical entity then you can specify the entity type here.
- `user_func` (optional): You can provide a function name for the sensors value to be processed through (i.e. Convert fahrenheit to celsius use `fahrenheit_to_celsius`)
For `options:` you have the following available:
- `divisor`: This is the divisor to use against the returned `value`.
- `multiplier`: This is the multiplier to use against the returned `value`.
- `skip_values`: This is an array of values we should skip over.
- `skip_values`: This is an array of values we should skip over (see note below).
- `skip_value_lt`: If sensor value is less than this, skip the discovery.
- `skip_value_gt`: If sensor value is greater than this, skip the discovery.
> `skip_values` can also compare items within the OID table against values. One example of this is:
```yaml
skip_values:
-
oid: sensUnit
op: '!='
value: 4
```
If you aren't able to use yaml to perform the sensor discovery, you will most likely need to use Advanced health discovery.
#### Advanced health discovery

View File

@@ -1037,6 +1037,9 @@ function discovery_process(&$valid, $device, $sensor_type, $pre_cache)
$warn_limit = is_numeric($data['warn_limit']) ? $data['warn_limit'] : dynamic_discovery_get_value('warn_limit', $index, $data, $pre_cache, 'null');
$high_limit = is_numeric($data['high_limit']) ? $data['high_limit'] : dynamic_discovery_get_value('high_limit', $index, $data, $pre_cache, 'null');
$entPhysicalIndex = str_replace('{{ $index }}', $index, $data['entPhysicalIndex']) ?: null;
$entPhysicalIndex_measured = isset($data['entPhysicalIndex_measured']) ? $data['entPhysicalIndex_measured'] : null;
$sensor_name = $device['os'];
if (isset($user_function) && function_exists($user_function)) {
@@ -1056,7 +1059,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, 'snmp', null, null, $user_function);
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', $entPhysicalIndex, $entPhysicalIndex_measured, $user_function);
if ($sensor_type === 'state') {
create_sensor_to_state_index($device, $sensor_name, $uindex);