adding POE polling

git-svn-id: http://www.observium.org/svn/observer/trunk@500 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-10-29 09:28:43 +00:00
parent 4ce992afb1
commit 5a6b6dcf3e
4 changed files with 49 additions and 1 deletions

View File

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

View File

@@ -0,0 +1,20 @@
<?php
if($device['os'] == "IOS") {
$array = snmp_cache_portIfIndex ($device, $array);
$cpe_oids = array("cpeExtPsePortEnable", "cpeExtPsePortDiscoverMode", "cpeExtPsePortDeviceDetected", "cpeExtPsePortIeeePd", "cpeExtPsePortAdditionalStatus", "cpeExtPsePortPwrMax", "cpeExtPsePortPwrAllocated", "cpeExtPsePortPwrAvailable", "cpeExtPsePortPwrConsumption", "cpeExtPsePortMaxPwrDrawn", "cpeExtPsePortEntPhyIndex", "cpeExtPsePortEntPhyIndex", "cpeExtPsePortPolicingCapable", "cpeExtPsePortPolicingEnable", "cpeExtPsePortPolicingAction", "cpeExtPsePortPwrManAlloc");
$peth_oids = array("pethPsePortAdminEnable", "pethPsePortPowerPairsControlAbility", "pethPsePortPowerPairs", "pethPsePortDetectionStatus", "pethPsePortPowerPriority", "pethPsePortMPSAbsentCounter", "pethPsePortType", "pethPsePortPowerClassifications", "pethPsePortInvalidSignatureCounter", "pethPsePortPowerDeniedCounter", "pethPsePortOverLoadCounter", "pethPsePortShortCounter");
$sub_start = utime();
echo("Caching Oids: ");
foreach ($cpe_oids as $oid) { echo("$oid "); $array = snmp_cache_slotport_oid($oid, $device, $array, "CISCO-POWER-ETHERNET-EXT-MIB"); }
foreach ($peth_oids as $oid) { echo("$oid "); $array = snmp_cache_slotport_oid($oid, $device, $array, "POWER-ETHERNET-MIB"); }
$end = utime(); $run = $end - $sub_start; $proctime = substr($run, 0, 5);
echo("\n$proctime secs\n");
}
?>

View File

@@ -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");
?>

View File

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