ignore Wrong Type errors in snpm_get and snmp_get_multi_oid (#12800)

Works around some awfully broken devices.
This commit is contained in:
Tony Murray
2021-05-02 07:38:12 -05:00
committed by GitHub
parent ec949d9a34
commit f7586973c9

View File

@@ -228,8 +228,8 @@ function snmp_get_multi_oid($device, $oids, $options = '-OUQn', $mib = null, $mi
$data = [];
foreach (array_chunk($oids, $oid_limit) as $chunk) {
$cmd = gen_snmpget_cmd($device, $chunk, $options, $mib, $mibdir);
$result = trim(external_exec($cmd));
$output = external_exec(gen_snmpget_cmd($device, $chunk, $options, $mib, $mibdir));
$result = trim(str_replace('Wrong Type (should be OBJECT IDENTIFIER): ', '', $output));
if ($result) {
$data = array_merge($data, explode("\n", $result));
}
@@ -278,8 +278,9 @@ function snmp_get($device, $oid, $options = null, $mib = null, $mibdir = null)
throw new Exception("snmp_get called for multiple OIDs: $oid");
}
$cmd = gen_snmpget_cmd($device, $oid, $options, $mib, $mibdir);
$data = trim(external_exec($cmd), "\\\" \n\r");
$output = external_exec(gen_snmpget_cmd($device, $oid, $options, $mib, $mibdir));
$output = str_replace('Wrong Type (should be OBJECT IDENTIFIER): ', '', $output);
$data = trim($output, "\\\" \n\r");
recordSnmpStatistic('snmpget', $time_start);
if (preg_match('/(No Such Instance|No Such Object|No more variables left|Authentication failure)/i', $data)) {