added oids.no_bulk os setting (#13666)

* forcewalk param

* [snmp][no_bulk]

* var names, test, schema

* Key off OIDs, not mibs

luminato is POC and needs to be reverted before merge.

* fix up os schema

* docs

* remove luminato arbitrary changes

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
Peca Nesovanovic
2022-01-15 16:59:23 +01:00
committed by GitHub
parent 3e0d8b8a24
commit 592a0efa51
8 changed files with 5074 additions and 4 deletions

View File

@@ -269,7 +269,7 @@ class NetSnmpQuery implements SnmpQueryInterface
private function buildCli(string $command, array $oids): array
{
$cmd = $this->initCommand($command);
$cmd = $this->initCommand($command, $oids);
array_push($cmd, '-M', $this->mibDirectories());
@@ -349,9 +349,13 @@ class NetSnmpQuery implements SnmpQueryInterface
return new SnmpResponse($output, $stderr, $exitCode);
}
private function initCommand(string $binary): array
private function initCommand(string $binary, array $oids): array
{
if ($binary == 'snmpwalk' && $this->device->snmpver !== 'v1' && Config::getOsSetting($this->device->os, 'snmp_bulk', true)) {
if ($binary == 'snmpwalk'
&& $this->device->snmpver !== 'v1'
&& Config::getOsSetting($this->device->os, 'snmp_bulk', true)
&& empty(array_intersect($oids, Config::getCombined($this->device->os, 'oids.no_bulk'))) // skip for oids that do not work with bulk
) {
$snmpcmd = [Config::get('snmpbulkwalk', 'snmpbulkwalk')];
$max_repeaters = $this->device->getAttrib('snmp_max_repeaters') ?: Config::getOsSetting($this->device->os, 'snmp.max_repeaters', Config::get('snmp.max_repeaters', false));

View File

@@ -122,6 +122,15 @@ snmpwalk for an OS set the following.
snmp_bulk: false
```
If only some specific OIDs fail with snmpbulkwalk. You can disable just those OIDs.
This needs to match exactly the OID being walked by LibreNMS. MIB::oid is preferred to prevent name collisions.
```yaml
oids:
no_bulk:
- UCD-SNMP-MIB::laLoadInt
```
#### Limit the oids per snmpget
```yaml

View File

@@ -130,7 +130,10 @@ function gen_snmpget_cmd($device, $oids, $options = null, $mib = null, $mibdir =
*/
function gen_snmpwalk_cmd($device, $oids, $options = null, $mib = null, $mibdir = null)
{
if ($device['snmpver'] == 'v1' || (isset($device['os']) && Config::getOsSetting($device['os'], 'snmp_bulk', true) == false)) {
if ($device['snmpver'] == 'v1'
|| (isset($device['os']) && (Config::getOsSetting($device['os'], 'snmp_bulk', true) == false
|| ! empty(array_intersect(Arr::wrap($oids), Config::getCombined($device['os'], 'oids.no_bulk'))))) // skip for oids that do not work with bulk
) {
$snmpcmd = [Config::get('snmpwalk')];
} else {
$snmpcmd = [Config::get('snmpbulkwalk')];

View File

@@ -5145,6 +5145,13 @@
"type": "integer",
"default": 0
},
"snmp.oids.no_bulk": {
"group": "poller",
"section": "snmp",
"order": 20,
"type": "array",
"default": null
},
"snmp.timeout": {
"group": "poller",
"section": "snmp",

View File

@@ -363,6 +363,15 @@
"type": "string"
}
},
"oids": {
"type": "object",
"properties": {
"no_bulk": {
"type": "array"
}
},
"additionalProperties": false
},
"snmp_bulk": {
"type": "boolean"
},

View File

@@ -1367,6 +1367,12 @@ return [
'description' => 'Max Repeaters',
'help' => 'Set repeaters to use for SNMP bulk requests',
],
'oids' => [
'no_bulk' => [
'description' => 'Disable snmp bulk for OIDs',
'help' => 'Disable snmp bulk operation for certain OIDs. Generally, this should be set on an OS instead. Format should be MIB::OID',
],
],
'port' => [
'description' => 'Port',
'help' => 'Set the tcp/udp port to be used for SNMP',

3541
tests/data/luminato_4x4.json Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff