fix: snmpwalk_group tables not using entries. (#7427)

When walking an arbitrary oid, it may not be grouped properly if the address ends with .0

For example: channelInternalTxAborted[11].0
This commit is contained in:
Tony Murray
2017-10-04 13:50:26 -05:00
committed by Neil Lathwood
parent 01a48496c8
commit bc8103774b

View File

@@ -552,6 +552,11 @@ function snmpwalk_group($device, $oid, $mib = '', $depth = 1, $array = array())
$parts = $parts[1];
array_splice($parts, $depth, 0, array_shift($parts)); // move the oid name to the correct depth
// some tables don't use entries so they end with .0
if (end($parts) == '.0') {
array_pop($parts);
}
$line = strtok("\n"); // get the next line and concatenate multi-line values
while ($line !== false && !str_contains($line, '=')) {
$value .= $line . PHP_EOL;
@@ -561,7 +566,7 @@ function snmpwalk_group($device, $oid, $mib = '', $depth = 1, $array = array())
// merge the parts into an array, creating keys if they don't exist
$tmp = &$array;
foreach ($parts as $part) {
$tmp = &$tmp[trim($part, '"')];
$tmp = &$tmp[trim($part, '".')];
}
$tmp = trim($value, "\" \n\r"); // assign the value as the leaf
}