From bc8103774b23bc0c7415683f01bfa4b002e3d4c2 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Wed, 4 Oct 2017 13:50:26 -0500 Subject: [PATCH] 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 --- includes/snmp.inc.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index d83d6acc4b..b194ebdaaa 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -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 }