mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Allow filtering of Health sensor discovery (#10485)
* Filter sensor types or by regexp * codeclimate * codeclimate
This commit is contained in:
@@ -16,6 +16,35 @@ For example, to set an alternate icon for ios:
|
||||
$config['os']['ios']['icon'] = 'fuzzybunny';
|
||||
```
|
||||
|
||||
### Ignoring Sensors
|
||||
|
||||
It is possible to filter some sensors from the configuration:
|
||||
|
||||
- Filter all 'current' sensors for Operating System 'vrp'.
|
||||
|
||||
```php
|
||||
$config['os']['vrp']['disabled_sensors']['current'] = true;
|
||||
```
|
||||
|
||||
- Filter all sensors matching regexp ``` '/PEM Iout/' ``` for
|
||||
Operating System iosxe.
|
||||
|
||||
```php
|
||||
$config['os']['iosxe']['disabled_sensors_regex'][] = '/PEM Iout/';
|
||||
```
|
||||
|
||||
- Ignore all temperature sensors
|
||||
|
||||
```php
|
||||
$config['disabled_sensors']['current'] = true;
|
||||
```
|
||||
|
||||
- Filter all sensors matching regexp ``` '/PEM Iout/' ```.
|
||||
|
||||
```php
|
||||
$config['disabled_sensors_regex'][] = '/PEM Iout/';
|
||||
```
|
||||
|
||||
### Ignoring Interfaces
|
||||
See also: [Global Ignoring Interfaces Config](../../Support/Configuration.md#interfaces-to-be-ignored)
|
||||
|
||||
|
||||
@@ -721,6 +721,35 @@ these are not provided by the vendor, the guess method can be disabled:
|
||||
$config['sensors']['guess_limits'] = false;
|
||||
```
|
||||
|
||||
# Ignoring Health Sensors
|
||||
|
||||
It is possible to filter some sensors from the configuration:
|
||||
|
||||
- Ignore all temperature sensors
|
||||
|
||||
```php
|
||||
$config['disabled_sensors']['current'] = true;
|
||||
```
|
||||
|
||||
- Filter all sensors matching regexp ``` '/PEM Iout/' ```.
|
||||
|
||||
```php
|
||||
$config['disabled_sensors_regex'][] = '/PEM Iout/';
|
||||
```
|
||||
|
||||
- Filter all 'current' sensors for Operating System 'vrp'.
|
||||
|
||||
```php
|
||||
$config['os']['vrp']['disabled_sensors']['current'] = true;
|
||||
```
|
||||
|
||||
- Filter all sensors matching regexp ``` '/PEM Iout/' ``` for
|
||||
Operating System iosxe.
|
||||
|
||||
```php
|
||||
$config['os']['iosxe']['disabled_sensors_regex'][] = '/PEM Iout/';
|
||||
```
|
||||
|
||||
# Storage configuration
|
||||
|
||||
Mounted storage / mount points to ignore in discovery and polling.
|
||||
|
||||
@@ -228,6 +228,9 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr,
|
||||
if (!is_numeric($divisor)) {
|
||||
$divisor = 1;
|
||||
}
|
||||
if (can_skip_sensor($device, $type, $descr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
d_echo("Discover sensor: $oid, $index, $type, $descr, $poller_type, $divisor, $multiplier, $entPhysicalIndex, $current, (limits: LL: $low_limit, LW: $low_warn_limit, W: $warn_limit, H: $high_limit)\n");
|
||||
|
||||
@@ -991,7 +994,7 @@ function ignore_storage($os, $descr)
|
||||
*/
|
||||
function discovery_process(&$valid, $device, $sensor_type, $pre_cache)
|
||||
{
|
||||
if ($device['dynamic_discovery']['modules']['sensors'][$sensor_type]) {
|
||||
if ($device['dynamic_discovery']['modules']['sensors'][$sensor_type] && ! can_skip_sensor($device, $sensor_type, '')) {
|
||||
$sensor_options = array();
|
||||
if (isset($device['dynamic_discovery']['modules']['sensors'][$sensor_type]['options'])) {
|
||||
$sensor_options = $device['dynamic_discovery']['modules']['sensors'][$sensor_type]['options'];
|
||||
@@ -1041,7 +1044,8 @@ function discovery_process(&$valid, $device, $sensor_type, $pre_cache)
|
||||
|
||||
d_echo("Final sensor value: $value\n");
|
||||
|
||||
if (YamlDiscovery::canSkipItem($value, $index, $data, $sensor_options, $pre_cache) === false && is_numeric($value)) {
|
||||
$skippedFromYaml = YamlDiscovery::canSkipItem($value, $index, $data, $sensor_options, $pre_cache);
|
||||
if ($skippedFromYaml === false && is_numeric($value)) {
|
||||
$oid = str_replace('{{ $index }}', $index, $data['num_oid']);
|
||||
|
||||
// process the description
|
||||
@@ -1315,6 +1319,27 @@ function add_cbgp_peer($device, $peer, $afi, $safi)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check if we should skip this sensor from discovery
|
||||
* @param $device
|
||||
* @param string $sensor_type
|
||||
* @param string $sensor_descr
|
||||
* @return bool
|
||||
*/
|
||||
function can_skip_sensor($device, $sensor_type = '', $sensor_descr = '')
|
||||
{
|
||||
if (! empty($sensor_type) && Config::getCombined($device['os'], "disabled_sensors.$sensor_type", false)) {
|
||||
return true;
|
||||
}
|
||||
foreach (Config::getCombined($device['os'], "disabled_sensors_regex", []) as $skipRegex) {
|
||||
if (! empty($sensor_descr) && preg_match($skipRegex, $sensor_descr)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* check if we should skip this device from discovery
|
||||
* @param string $sysName
|
||||
|
||||
Reference in New Issue
Block a user