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:
@@ -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;
|
||||
|
||||
@@ -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