mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
SnmpQuery numeric accept a boolean (#14565)
This commit is contained in:
@@ -188,9 +188,11 @@ class NetSnmpQuery implements SnmpQueryInterface
|
||||
/**
|
||||
* Output all OIDs numerically
|
||||
*/
|
||||
public function numeric(): SnmpQueryInterface
|
||||
public function numeric(bool $numeric = true): SnmpQueryInterface
|
||||
{
|
||||
$this->options = array_merge($this->options, ['-On']);
|
||||
$this->options = $numeric
|
||||
? array_merge($this->options, ['-On'])
|
||||
: array_diff($this->options, ['-On']);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ interface SnmpQueryInterface
|
||||
/**
|
||||
* Output all OIDs numerically
|
||||
*/
|
||||
public function numeric(): SnmpQueryInterface;
|
||||
public function numeric(bool $numeric = true): SnmpQueryInterface;
|
||||
|
||||
/**
|
||||
* Hide MIB in output
|
||||
|
@@ -65,13 +65,9 @@ class SnmpFetch extends LnmsCommand
|
||||
$output = $this->option('output')
|
||||
?: ($type == 'walk' ? 'table' : 'value');
|
||||
|
||||
$query = SnmpQuery::make();
|
||||
if ($this->option('numeric')) {
|
||||
$query->numeric();
|
||||
}
|
||||
|
||||
/** @var \LibreNMS\Data\Source\SnmpResponse $res */
|
||||
$res = $query->$type($this->argument('oid'));
|
||||
$res = SnmpQuery::numeric($this->option('numeric'))
|
||||
->$type($this->argument('oid'));
|
||||
|
||||
if (! $res->isValid()) {
|
||||
$this->warn(trans('commands.snmp:fetch.failed'));
|
||||
|
@@ -130,9 +130,9 @@ class SnmpQueryMock implements SnmpQueryInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function numeric(): SnmpQueryInterface
|
||||
public function numeric(bool $numeric = true): SnmpQueryInterface
|
||||
{
|
||||
$this->numeric = true;
|
||||
$this->numeric = $numeric;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user