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
This commit is contained in:
Adam Amstrong
2010-02-08 03:36:07 +00:00
parent 8e46ec5cbd
commit ef8eacc334
2 changed files with 20 additions and 12 deletions

View File

@@ -1,5 +1,23 @@
<?php
function snmp_walk($hostname, $port,$snmpver, $community, $oid, $options, $mib) {
global $debug; global $config; global $runtime_stats;
$cmd = ($snmpver == 'v1' ? $config['snmpwalk'] : $config['snmpbulkwalk']) . " -" . $snmpver . " -c " . $community . " " . $hostname.":".$port . " ";
if($options) { $cmd .= "-$options "; }
if($mib) { $cmd .= "-m $mib "; }
$cmd .= $oid;
if($debug) { echo("$cmd\n"); }
$data = trim(shell_exec($cmd));
$runtime_stats['snmpwalk']++;
if($debug) { echo("$data\n"); }
if (is_string($result) && (preg_match("/No Such (Object|Instance)/i", $result) || preg_match("/No more variables left/i", $result)))
{
$result = false;
} else {
return $data;
}
}
function snmp_cache_cip($oid, $device, $array, $mib = 0) {
global $config;
$cmd = ($device['snmpver'] == 'v1' ? $config['snmpwalk'] : $config['snmpbulkwalk']) . " -O snQ -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";