mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix for lnms snmp:translate (#16159)
Wasn't handling things correctly Disable numeric if the oid is already numeric and add ALL mibs
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Models\Device;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Data\Source\SnmpResponse;
|
use LibreNMS\Data\Source\SnmpResponse;
|
||||||
|
use LibreNMS\Util\Oid;
|
||||||
use SnmpQuery;
|
use SnmpQuery;
|
||||||
|
|
||||||
class SnmpTranslate extends SnmpFetch
|
class SnmpTranslate extends SnmpFetch
|
||||||
@@ -37,6 +38,14 @@ class SnmpTranslate extends SnmpFetch
|
|||||||
$res = new SnmpResponse('');
|
$res = new SnmpResponse('');
|
||||||
// translate does not support multiple oids (should it?)
|
// translate does not support multiple oids (should it?)
|
||||||
foreach ($this->oids as $oid) {
|
foreach ($this->oids as $oid) {
|
||||||
|
if (Oid::isNumeric($oid)) {
|
||||||
|
$translated = SnmpQuery::numeric(false)->mibs(['ALL'])->translate($oid);
|
||||||
|
$response = new SnmpResponse($translated . PHP_EOL);
|
||||||
|
$res = $res->append($response);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$translated = SnmpQuery::numeric($this->numeric)->translate($oid);
|
$translated = SnmpQuery::numeric($this->numeric)->translate($oid);
|
||||||
|
|
||||||
// if we got the same back (ignoring . prefix) swap numeric
|
// if we got the same back (ignoring . prefix) swap numeric
|
||||||
@@ -44,7 +53,7 @@ class SnmpTranslate extends SnmpFetch
|
|||||||
$translated = SnmpQuery::numeric(! $this->numeric)->translate($oid);
|
$translated = SnmpQuery::numeric(! $this->numeric)->translate($oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
$res->append(new SnmpResponse($translated . PHP_EOL));
|
$res = $res->append(new SnmpResponse($translated . PHP_EOL));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
|
Reference in New Issue
Block a user