From b89ebabeccbd7948aa0f54e9736d602e78bb2126 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Fri, 28 Oct 2016 07:02:09 +0100 Subject: [PATCH] Feature: Added support for global max repeaters for snmp (#4880) * Feature: Added support for global max repeaters for snmp * added phpdoc --- doc/Support/Performance.md | 13 ++++++++++++- includes/snmp.inc.php | 21 ++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/doc/Support/Performance.md b/doc/Support/Performance.md index 66af33d48b..f4fc343fa8 100644 --- a/doc/Support/Performance.md +++ b/doc/Support/Performance.md @@ -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 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 -M /opt/librenms/mibs -m IF-MIB` +`time snmpbulkwalk -v2c -cpublic HOSTNAME -Cr -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 diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index c10f82a794..92d5c7498a 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -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; + } +}