Move MIB poller debugging into SNMP functions

This commit is contained in:
Paul Gear
2015-06-14 09:09:54 +10:00
parent d617aaacd0
commit 0e218ef22c
2 changed files with 10 additions and 7 deletions

View File

@@ -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");
?>

View File

@@ -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");
}
?>