From 86a96e2d42bb52155ce344c94b00ead196d29269 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 17 Dec 2018 07:59:40 -0600 Subject: [PATCH] Fix snmp-collect-data.php (#9553) --- LibreNMS/Util/ModuleTestHelper.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/LibreNMS/Util/ModuleTestHelper.php b/LibreNMS/Util/ModuleTestHelper.php index 9661816a2e..718d2bc860 100644 --- a/LibreNMS/Util/ModuleTestHelper.php +++ b/LibreNMS/Util/ModuleTestHelper.php @@ -189,7 +189,7 @@ class ModuleTestHelper $collection_output = preg_replace('/\033\[[\d;]+m/', '', $collection_output); // extract snmp queries - $snmp_query_regex = '/SNMP\[.*snmp(?:bulk)?([a-z]+) .+:HOSTNAME:[0-9]+(.+)\]/'; + $snmp_query_regex = '/SNMP\[.*snmp(?:bulk)?([a-z]+)\' .+:HOSTNAME:[0-9]+\' \'(.+)\'\]/'; preg_match_all($snmp_query_regex, $collection_output, $snmp_matches); // extract mibs and group with oids @@ -198,10 +198,11 @@ class ModuleTestHelper 'sysObjectID.0_get' => ['oid' => 'sysObjectID.0', 'mib' => 'SNMPv2-MIB', 'method' => 'get'], ]; foreach ($snmp_matches[0] as $index => $line) { - preg_match('/-m \+?([a-zA-Z0-9:\-]+)/', $line, $mib_matches); + preg_match("/'-m' '\+?([a-zA-Z0-9:\-]+)'/", $line, $mib_matches); $mib = $mib_matches[1]; $method = $snmp_matches[1][$index]; - $oids = explode(' ', trim($snmp_matches[2][$index])); + $oids = explode("' '", trim($snmp_matches[2][$index])); + foreach ($oids as $oid) { $snmp_oids["{$oid}_$method"] = [ 'oid' => $oid,