snmp_max_oid per Os support and snmpv1 multi_oid fix (#9343)

* Added snmp_max_oid config at Os level.

* Added check for snmpv1 on multi_oid requests.

* Check  device_oid_limit on multi get

* Use array_chunk

* Update snmp.inc.php

* remove dump, unused variable and extra plodes

* per device settings should take priority over OS

* Update Settings.md

* don't discard the data :P
This commit is contained in:
Alan Gregory
2018-11-21 17:25:39 -02:00
committed by Tony Murray
parent e4ac31890e
commit c78f92a4c2
4 changed files with 45 additions and 24 deletions

View File

@@ -47,14 +47,6 @@ ifalias: true
ifindex: true
```
### Disable snmpbulkwalk
Some devices have buggy snmp implementations and don't respond well to the more efficient snmpbulkwalk.
To disable snmpbulkwalk and only use snmpwalk for an os set the following.
```yaml
nobulk: true
```
### Poller and Discovery Modules
The various discovery and poller modules can be enabled or disabled per OS. The defaults are usually reasonable, so likely you won't want to change more than a few.
These modules can be enabled or disabled per-device in the webui and per os or globally in config.php.
@@ -67,11 +59,26 @@ discovery_modules:
arp-table: false
```
### SNMP Settings
#### Disable snmpbulkwalk
Some devices have buggy snmp implementations and don't respond well to the more efficient snmpbulkwalk.
To disable snmpbulkwalk and only use snmpwalk for an os set the following.
```yaml
nobulk: true
```
#### Limit the oids per snmpget
```yaml
snmp_max_oid: 8
```
### Storage Settings
See also: [Global Storage Config](../../Support/Configuration.md#storage-configuration)
```yaml
ignore_mount array: # exact match
ignore_mount_array: # exact match
- /var/run
ignore_mount_string: # substring
- run

View File

@@ -2497,17 +2497,20 @@ function db_schema_is_current()
*/
function get_device_oid_limit($device)
{
global $config;
$max_oid = $device['snmp_max_oid'];
if (isset($max_oid) && $max_oid > 0) {
return $max_oid;
} elseif (isset($config['snmp']['max_oid']) && $config['snmp']['max_oid'] > 0) {
return $config['snmp']['max_oid'];
} else {
return 10;
// device takes priority
if ($device['snmp_max_oid'] > 0) {
return $device['snmp_max_oid'];
}
// then os
$os_max = Config::getOsSetting($device['os'], 'snmp_max_oid', 0);
if ($os_max > 0) {
return $os_max;
}
// then global
$global_max = Config::get('snmp.max_oid', 10);
return $global_max > 0 ? $global_max : 10;
}
/**

View File

@@ -221,17 +221,25 @@ function snmp_get_multi($device, $oids, $options = '-OQUs', $mib = null, $mibdir
function snmp_get_multi_oid($device, $oids, $options = '-OUQn', $mib = null, $mibdir = null)
{
$time_start = microtime(true);
$oid_limit = get_device_oid_limit($device);
if (is_array($oids)) {
$oids = implode(' ', $oids);
if (!is_array($oids)) {
$oids = explode(" ", $oids);
}
$cmd = gen_snmpget_cmd($device, $oids, $options, $mib, $mibdir);
$data = trim(external_exec($cmd));
$data = [];
foreach (array_chunk($oids, $oid_limit) as $chunk) {
$partial_oids = implode(' ', $chunk);
$cmd = gen_snmpget_cmd($device, $partial_oids, $options, $mib, $mibdir);
$result = trim(external_exec($cmd));
if ($result) {
$data = array_merge($data, explode("\n", $result));
}
}
$array = array();
$oid = '';
foreach (explode("\n", $data) as $entry) {
foreach ($data as $entry) {
if (str_contains($entry, '=')) {
list($oid,$value) = explode('=', $entry, 2);
$oid = trim($oid);

View File

@@ -339,6 +339,9 @@
"nobulk": {
"type": "boolean"
},
"snmp_max_oid": {
"type": "string"
},
"ifXmcbc": {
"type": "boolean"
},