Feature: Added support for global max repeaters for snmp (#4880)

* Feature: Added support for global max repeaters for snmp

* added phpdoc
This commit is contained in:
Neil Lathwood
2016-10-28 07:02:09 +01:00
committed by Daniel Preussker
parent 7d94f19b7d
commit b89ebabecc
2 changed files with 32 additions and 2 deletions

View File

@ -42,13 +42,24 @@ You can disable modules globally then re-enable the module per device or the opp
We have support for SNMP Max repeaters which can be handy on devices where we poll a lot of ports or bgp sessions for instance and
where snmpwalk or snmpbulkwalk is used. This needs to be enabled on a per device basis under edit device -> snmp -> Max repeaters.
You can also set this globally with the config option `$config['snmp']['max_repeaters'] = X;`.
It's advisable to test the time taken to snmpwalk IF-MIB or something similar to work out what the best value is. To do this run the following
but replace <REPEATERS> with varying numbers from 10 upto around 50. You will also need to set the correct snmp version, hostname and community string:
`time snmpbulkwalk -v2c -cpublic HOSTNAME -Cr<REPEATERS> -M /opt/librenms/mibs -m IF-MIB`
`time snmpbulkwalk -v2c -cpublic HOSTNAME -Cr<REPEATERS> -M /opt/librenms/mibs -m IF-MIB IfEntry`
> NOTE: Do not go blindly setting this value as you can impact polling negatively.
#### SNMP Max OIDs
For sensors polling we now do bulk snmp gets to speed things up. By default this is ten but you can overwrite this per device under
edit device -> snmp -> Max OIDs.
You can also set this globally with the config option `$config['snmp']['max_oid'] = X;`.
> NOTE: It is advisable to monitor sensor polling when you change this to ensure you don't set the value too high.
#### Optimise poller-wrapper
The default 16 threads that `poller-wrapper.py` runs as isn't necessarily the optimal number. A general rule of thumb is

View File

@ -102,7 +102,7 @@ function gen_snmpwalk_cmd($device, $oids, $options = null, $mib = null, $mibdir
$snmpcmd = $config['snmpwalk'];
} else {
$snmpcmd = $config['snmpbulkwalk'];
$max_repeaters = $device['snmp_max_repeaters'];
$max_repeaters = get_device_max_repeaters($device);
if ($max_repeaters > 0) {
$snmpcmd .= " -Cr$max_repeaters ";
}
@ -1147,3 +1147,22 @@ function snmpwalk_array_num($device, $oid, $indexes = 1)
}
return $array;
}
/**
* @param $device
* @return bool
*/
function get_device_max_repeaters($device)
{
global $config;
$max_repeaters = $device['snmp_max_repeaters'];
if (isset($max_repeaters) && $max_repeaters > 0) {
return $max_repeaters;
} elseif (isset($config['snmp']['max_repeaters']) && $config['snmp']['max_repeaters'] > 0) {
return $config['snmp']['max_repeaters'];
} else {
return false;
}
}