mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
SnmpQuery walk multiple oids (#14015)
Makes it easier to walk select oids from a large table. Walking oids with different indexes will break some logic and is undefined so far.
This commit is contained in:
@@ -243,7 +243,7 @@ class NetSnmpQuery implements SnmpQueryInterface
|
||||
*/
|
||||
public function walk($oid): SnmpResponse
|
||||
{
|
||||
return $this->exec('snmpwalk', $this->parseOid($oid));
|
||||
return $this->execMultiple('snmpwalk', $this->parseOid($oid));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -330,6 +330,19 @@ class NetSnmpQuery implements SnmpQueryInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function execMultiple(string $command, array $oids): ?SnmpResponse
|
||||
{
|
||||
$combined = null;
|
||||
|
||||
foreach ($oids as $oid) {
|
||||
$response = $this->exec($command, [$oid]);
|
||||
|
||||
$combined = $combined ? $combined->append($response) : $response;
|
||||
}
|
||||
|
||||
return $combined;
|
||||
}
|
||||
|
||||
private function exec(string $command, array $oids): SnmpResponse
|
||||
{
|
||||
$measure = Measurement::start($command);
|
||||
|
Reference in New Issue
Block a user