From 0e218ef22c305d0d83c416918935b6a8861df012 Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Sun, 14 Jun 2015 09:09:54 +1000 Subject: [PATCH] Move MIB poller debugging into SNMP functions --- includes/polling/mib.inc.php | 5 ----- includes/snmp.inc.php | 12 ++++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/includes/polling/mib.inc.php b/includes/polling/mib.inc.php index 8488b2064..857733cef 100644 --- a/includes/polling/mib.inc.php +++ b/includes/polling/mib.inc.php @@ -11,12 +11,7 @@ * the source code distribution for details. */ -echo("MIB-based polling"); -d_echo("\n", ": "); - $devicemib = array($device['sysObjectID'] => "all"); poll_mibs($devicemib, $device, $graphs); -d_echo("Done MIB-based polling"); -echo("\n"); ?> diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index 5713ccdf0..b1fda71f5 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -942,7 +942,7 @@ function snmp_translate($oid, $module, $mibdir = null) $cmd .= " -m $module $oid"; // load all the MIBs looking for our object $cmd .= " 2>/dev/null"; // ignore invalid MIBs - $lines = preg_split('/\n+/', shell_exec($cmd)); + $lines = preg_split('/\n+/', external_exec($cmd)); if (!$lines) { d_echo("No results from snmptranslate\n"); return null; @@ -1075,19 +1075,27 @@ function poll_mibs($list, $device, &$graphs) return; } $mibdefs = array(); + echo("MIB-based polling:"); + d_echo("\n"); + foreach ($list as $name => $module) { $translated = snmp_translate($name, $module); if ($translated) { + echo(" $module::$name"); + d_echo("\n"); $mod = $translated[0]; $nam = $translated[1]; $mibdefs[$nam] = snmp_mib_load($nam, $mod); - $oids = snmpwalk_cache_oid($device, "$mod::$nam", array(), $mod); + $oids = snmpwalk_cache_oid($device, $nam, array(), $mod, null, "-OQUsb"); + d_print_r($oids); save_mibs($device, $nam, $oids, $mibdefs[$nam], $graphs); } else { d_echo("MIB: no match for $module::$name\n"); } } + d_echo("Done MIB-based polling"); + echo("\n"); } ?>