git-svn-id: http://www.observium.org/svn/observer/trunk@481 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-10-09 08:33:01 +00:00
parent b4c80a1c85
commit 6fcbf53bc6
2 changed files with 79 additions and 1 deletions
+24 -1
View File
@@ -1,5 +1,18 @@
<?php
if($device['os'] == "CatOS" || $device['os'] == "IOS") {
$portifIndex = array();
$cmd = $config['snmpwalk'] . " -CI -m CISCO-STACK-MIB -O q -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " portIfIndex";
echo("$cmd");
$portifIndex_output = trim(shell_exec($cmd));
foreach(explode("\n", $portifIndex_output) as $entry){
$entry = str_replace("CISCO-STACK-MIB::portIfIndex.", "", $entry);
list($slotport, $ifIndex) = explode(" ", $entry);
$portifIndex[$ifIndex] = $slotport;
}
# print_r($portifIndex);
}
$interface_query = mysql_query("SELECT * FROM `interfaces` $where");
while ($interface = mysql_fetch_array($interface_query)) {
@@ -38,6 +51,14 @@ while ($interface = mysql_fetch_array($interface_query)) {
$ifDescr = trim(str_replace("\"", "", $ifDescr));
$ifDescr = trim($ifDescr);
$ifIndex = $interface['ifIndex'];
if($portifIndex[$ifIndex]) {
if($device['os'] == "CatOS") {
$cmd = $config['snmpget'] . " -m CISCO-STACK-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " portName." . $portifIndex[$ifIndex];
$ifAlias = trim(shell_exec($cmd));
}
}
if($config[ifname][$device[os]]) { $ifDescr = $ifName; }
$rrdfile = $host_rrd . "/" . $interface['ifIndex'] . ".rrd";
@@ -97,7 +118,7 @@ while ($interface = mysql_fetch_array($interface_query)) {
$update_query = "UPDATE `interfaces` SET ";
$update_query .= $update;
$update_query .= " WHERE `interface_id` = '" . $interface['interface_id'] . "'";
echo("Updating : " . $device['hostname'] . " $ifDescr\nSQL :$update_query\n\n");
# echo("Updating : " . $device['hostname'] . " $ifDescr\nSQL :$update_query\n\n");
$update_result = mysql_query($update_query);
} else {
# echo("Not Updating : " . $device['hostname'] ." $ifDescr ( " . $interface['ifDescr'] . " )\n\n");
@@ -135,5 +156,7 @@ while ($interface = mysql_fetch_array($interface_query)) {
}
unset($portifIndex);
?>