From f27de0b8ff1e8ba6119cba0495e7ceb43c838f43 Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Mon, 8 Jun 2015 12:56:20 +1000 Subject: [PATCH] Remove duplicate code --- includes/snmp.inc.php | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index 68d119aeb..c9ff65ca0 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -322,9 +322,9 @@ function snmp_cache_ifIndex($device) return $array; } -function snmpwalk_cache_oid($device, $oid, $array, $mib = NULL, $mibdir = NULL) +function snmpwalk_cache_oid($device, $oid, $array, $mib = NULL, $mibdir = NULL, $snmpflags = "-OQUs") { - $data = snmp_walk($device, $oid, "-OQUs", $mib, $mibdir); + $data = snmp_walk($device, $oid, $snmpflags, $mib, $mibdir); foreach (explode("\n", $data) as $entry) { list($oid,$value) = explode("=", $entry, 2); @@ -345,20 +345,7 @@ function snmpwalk_cache_oid($device, $oid, $array, $mib = NULL, $mibdir = NULL) // to be the same. function snmpwalk_cache_oid_num($device, $oid, $array, $mib = NULL, $mibdir = NULL) { - $data = snmp_walk($device, $oid, "-OQUn", $mib, $mibdir); - - foreach (explode("\n", $data) as $entry) - { - list($oid,$value) = explode("=", $entry, 2); - $oid = trim($oid); $value = trim($value); - list($oid, $index) = explode(".", $oid, 2); - if (!strstr($value, "at this OID") && isset($oid) && isset($index)) - { - $array[$index][$oid] = $value; - } - } - - return $array; + return snmpwalk_cache_oid($device, $oid, $array, $mib, $mibdir, $snmpflags = "-OQUn"); }