mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Consolidate and improve snmptranslate usage (#14567)
* Consolidate and improve snmptranslate usage * Fix style * lint fixes * fix typo * allow multiple mib directories * Only add mib if it is not already set * oid first, in case we have key length issues * if there is a full oid, don't add other mibs * debug in ci * more debug in ci * better debug in ci * remove debug * Use numeric index * revert dlink change * Don't add -On twice * unit tests and hopefully better heuristics * remove dump and add one more set of tests * style fixes * handle bad input in old functions * shortcut whole snmp_translate function
This commit is contained in:
@@ -56,19 +56,23 @@ class SnmpFetch extends LnmsCommand
|
||||
}
|
||||
|
||||
$return = 0;
|
||||
$type = $this->option('type');
|
||||
$output = $this->option('output') ?: ($type == 'walk' ? 'table' : 'value');
|
||||
|
||||
foreach ($device_ids as $device_id) {
|
||||
DeviceCache::setPrimary($device_id);
|
||||
$this->info(DeviceCache::getPrimary()->displayName() . ':');
|
||||
|
||||
$type = $this->option('type');
|
||||
$output = $this->option('output')
|
||||
?: ($type == 'walk' ? 'table' : 'value');
|
||||
|
||||
/** @var \LibreNMS\Data\Source\SnmpResponse $res */
|
||||
$res = SnmpQuery::numeric($this->option('numeric'))
|
||||
->$type($this->argument('oid'));
|
||||
|
||||
if ($type == 'translate') {
|
||||
$this->line($res);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (! $res->isValid()) {
|
||||
$this->warn(trans('commands.snmp:fetch.failed'));
|
||||
$this->line($res->getErrorMessage());
|
||||
|
Reference in New Issue
Block a user