From ef8eacc3342a5ab1b3001f890121adaca27e17bc Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Mon, 8 Feb 2010 03:36:07 +0000 Subject: [PATCH] new snmp_walk function with basic logging. increments $runtime_stats['snmpwalk'] for stats. should do timekeeping for debug? git-svn-id: http://www.observium.org/svn/observer/trunk@790 61d68cd4-352d-0410-923a-c4978735b2b8 --- includes/discovery/interfaces.php | 14 ++------------ includes/functions-poller.inc.php | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/includes/discovery/interfaces.php b/includes/discovery/interfaces.php index 756f8b0c8..e023ca544 100755 --- a/includes/discovery/interfaces.php +++ b/includes/discovery/interfaces.php @@ -4,10 +4,8 @@ echo("Interfaces : "); - $cmd = ($device['snmpver'] == 'v1' ? $config['snmpwalk'] : $config['snmpbulkwalk']) . " -m IF-MIB -O nsq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; - $cmd .= " ifDescr"; - if ($debug) echo("$cmd\n"); - $interfaces = trim(shell_exec($cmd)); + $interfaces = snmp_walk($device['hostname'], $device['port'], $device['snmpver'], $device['community'], "ifDescr", "Onsq", "IF-MIB"); + $interfaces = str_replace("\"", "", $interfaces); $interfaces = str_replace("ifDescr.", "", $interfaces); $interfaces = str_replace(" ", "||", $interfaces); @@ -20,14 +18,6 @@ $entry = trim($entry); list($ifIndex, $ifDescr) = explode("||", $entry); -# if($config['ifdescr'][$device['os']]) { -# $ifDescr = shell_exec($config['snmpget'] . " -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ifDescr.$ifIndex"); -# $ifDescr = str_replace("No Such Object available on this agent at this OID", "", $ifDescr); -# $ifDescr = str_replace("No Such Instance currently exists at this OID", "", $ifDescr); -# $ifDescr = trim(str_replace("\"", "", $ifDescr)); -# } else { $ifDescr = trim(str_replace("\"", "", $ifName)); } - - if(!strstr($entry, "irtual")) { $if = trim(strtolower($ifDescr)); $nullintf = 0; diff --git a/includes/functions-poller.inc.php b/includes/functions-poller.inc.php index bc05377bd..e4573927b 100644 --- a/includes/functions-poller.inc.php +++ b/includes/functions-poller.inc.php @@ -1,5 +1,23 @@