diff --git a/includes/functions-poller.inc.php b/includes/functions-poller.inc.php index 66fe0c807..a08a8f07c 100644 --- a/includes/functions-poller.inc.php +++ b/includes/functions-poller.inc.php @@ -50,6 +50,28 @@ global $config; return $array; } +function snmp_cache_slotport_oid($oid, $device, $array, $mib = 0) { + global $config; + $cmd = $config['snmpbulkwalk'] . " -O Qs -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " "; + if($mib) { $cmd .= "-m $mib "; } + $cmd .= $oid; + $data = trim(shell_exec($cmd)); + $device_id = $device['device_id']; + #echo("Caching: $oid\n"); + foreach(explode("\n", $data) as $entry) { + $entry = str_replace($oid.".", "", $entry); + list($slotport, $value) = explode("=", $entry); + $slotport = trim($slotport); $value = trim($value); + if ($array[$device_id][$slotport]['ifIndex']) { + $ifIndex = $array[$device_id][$slotport]['ifIndex']; + #$array[$device_id][$slotport][$oid] = $value; + $array[$device_id][$ifIndex][$oid] = $value; + } + } + return $array; +} + + function snmp_cache_oid($oid, $device, $array, $mib = 0) { global $config; $cmd = $config['snmpbulkwalk'] . " -O Qs -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " "; @@ -97,6 +119,7 @@ function snmp_cache_portIfIndex ($device, $array) { global $config; $cmd = $config['snmpwalk'] . " -CI -m CISCO-STACK-MIB -O q -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " portIfIndex"; $output = trim(shell_exec($cmd)); + $device_id = $device['device_id']; #echo("Caching: portIfIndex\n"); foreach(explode("\n", $output) as $entry){ $entry = str_replace("CISCO-STACK-MIB::portIfIndex.", "", $entry); @@ -111,6 +134,7 @@ function snmp_cache_portName ($device, $array) { global $config; $cmd = $config['snmpwalk'] . " -CI -m CISCO-STACK-MIB -O Qs -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " portName"; $output = trim(shell_exec($cmd)); + $device_id = $device['device_id']; #echo("Caching: portName\n"); foreach(explode("\n", $output) as $entry){ $entry = str_replace("portName.", "", $entry); diff --git a/includes/polling/cisco-poe.inc.php b/includes/polling/cisco-poe.inc.php new file mode 100644 index 000000000..31c24503c --- /dev/null +++ b/includes/polling/cisco-poe.inc.php @@ -0,0 +1,20 @@ + diff --git a/poll-device.php b/poll-device.php index b2b3d30b3..8e32c38a5 100755 --- a/poll-device.php +++ b/poll-device.php @@ -292,5 +292,4 @@ $string = $argv[0] . " $doing " . date("F j, Y, G:i") . " - $i devices polled i echo("$string\n"); shell_exec("echo '".$string."' >> /opt/observer/observer.log"); - ?> diff --git a/test-poll.php b/test-poll.php index 57c683c7b..a5b54068d 100755 --- a/test-poll.php +++ b/test-poll.php @@ -3,6 +3,8 @@ include("config.php"); include("includes/functions.php"); +include("includes/functions-poller.inc.php"); + $poller_start = utime(); @@ -48,6 +50,9 @@ while ($device = mysql_fetch_array($device_query)) { include("includes/polling/".$type.".inc.php"); echo("\n"); $devices_polled++; + + unset($array); + } $poller_end = utime(); $poller_run = $poller_end - $poller_start; $poller_time = substr($poller_run, 0, 5);