mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Rename NetSnmp to SnmpQuery (#13344)
* Rename NetSnmp to SnmpQuery Always resolve a new instance. It was not expected to be a singleton, set options persisted. This means numeric() works properly now * fix snmpfetch call and style * Ability to set device from device array
This commit is contained in:
@@ -114,6 +114,23 @@ class SnmpQuery
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a device by a device array.
|
||||
* The device will be fetched from the cache if it is loaded, otherwise, it will fill the array into a new Device
|
||||
*/
|
||||
public function deviceArray(array $device): SnmpQuery
|
||||
{
|
||||
if (isset($device['device_id']) && DeviceCache::has($device['device_id'])) {
|
||||
$this->device = DeviceCache::get($device['device_id']);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->device = new Device($device);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a context for the snmp query
|
||||
* This is most commonly used to fetch alternate sets of data, such as different VRFs
|
||||
@@ -139,15 +156,9 @@ class SnmpQuery
|
||||
/**
|
||||
* Output all OIDs numerically
|
||||
*/
|
||||
public function numeric(bool $enabled = true): SnmpQuery
|
||||
public function numeric(): SnmpQuery
|
||||
{
|
||||
if ($enabled) {
|
||||
$this->options = array_merge($this->options, ['-On']);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->options = array_diff($this->options, ['-On']);
|
||||
$this->options = array_merge($this->options, ['-On']);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user