Optional automatic sensor limits (#9973)

* Automatic sensor limits are now optional. Set ['discovery']['sensors']['autolimit'] = false to disable.
* Changing new config variable name from discovery.sensors.autolimit to sensors.guess_limits
* Updated documentation: ['sensors']['guess_limits'] value added
This commit is contained in:
Yann Gauteron
2019-03-16 11:51:09 +01:00
committed by PipoCanaja
parent 6f8311369c
commit d15fda3693
3 changed files with 20 additions and 4 deletions

View File

@@ -580,6 +580,17 @@ $config['bad_entity_sensor_regex'][] = '/Physical id [0-9]+/';
$config['os']['cisco']['bad_entity_sensor_regex'] = '/Physical id [0-9]+/';
```
### Entity sensors limit values
Vendors may give some limit values (or thresholds) for the discovered sensors. By default, when no such value is given,
both high and low limit values are guessed, based on the value measured during the initial discovery.
When it is preferred to have no high and/or low limit values at all if these are not provided by the vendor, the guess
method can be disabled:
```php
$config['sensors']['guess_limits'] = false;
```
### Storage configuration
```php

View File

@@ -840,6 +840,9 @@ $config['discovery_modules']['fdb-table'] = true;
// Enable daily updates
$config['update'] = 1;
// Sets automatic sensor limits when no values are returned by the device.
$config['sensors']['guess_limits'] = true;
// Purge syslog and eventlog
$config['syslog_purge'] = 30;
// Number in days of how long to keep syslog entries for.

View File

@@ -218,6 +218,8 @@ function discover_device(&$device, $force_module = false)
// Discover sensors
function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, $divisor = 1, $multiplier = 1, $low_limit = null, $low_warn_limit = null, $warn_limit = null, $high_limit = null, $current = null, $poller_type = 'snmp', $entPhysicalIndex = null, $entPhysicalIndex_measured = null, $user_func = null, $group = null)
{
$guess_limits = Config::get('sensors.guess_limits', true);
$low_limit = set_null($low_limit);
$low_warn_limit = set_null($low_warn_limit);
$warn_limit = set_null($warn_limit);
@@ -235,11 +237,11 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr,
}
if (dbFetchCell('SELECT COUNT(sensor_id) FROM `sensors` WHERE `poller_type`= ? AND `sensor_class` = ? AND `device_id` = ? AND sensor_type = ? AND `sensor_index` = ?', array($poller_type, $class, $device['device_id'], $type, (string)$index)) == '0') {
if (is_null($high_limit)) {
if ($guess_limits && is_null($high_limit)) {
$high_limit = sensor_limit($class, $current);
}
if (is_null($low_limit)) {
if ($guess_limits && is_null($low_limit)) {
$low_limit = sensor_low_limit($class, $current);
}
@@ -285,7 +287,7 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr,
$sensor_entry = dbFetchRow('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? AND `sensor_type` = ? AND `sensor_index` = ?', array($class, $device['device_id'], $type, (string)$index));
if (!isset($high_limit)) {
if (!$sensor_entry['sensor_limit']) {
if ($guess_limits && !$sensor_entry['sensor_limit']) {
// Calculate a reasonable limit
$high_limit = sensor_limit($class, $current);
} else {
@@ -295,7 +297,7 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr,
}
if (!isset($low_limit)) {
if (!$sensor_entry['sensor_limit_low']) {
if ($guess_limits && !$sensor_entry['sensor_limit_low']) {
// Calculate a reasonable limit
$low_limit = sensor_low_limit($class, $current);
} else {