mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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:
@@ -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'] . " ";
|
||||
|
||||
Reference in New Issue
Block a user