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:
Tony Murray
2022-06-07 02:04:32 -05:00
committed by GitHub
parent 53a892acad
commit 82be234bae
2 changed files with 24 additions and 1 deletions

View File

@@ -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);