git-svn-id: http://www.observium.org/svn/observer/trunk@77 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2007-04-08 21:54:28 +00:00
parent 4e93fd0dd1
commit 055f74751c
3 changed files with 21 additions and 13 deletions

View File

@@ -14,11 +14,15 @@ while($interface = mysql_fetch_array($query)) {
if(is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
$speed = humanspeed($interface['ifSpeed']);
$if_link = generateiflink($interface, makeshortif($interface['ifDescr']));
$dev_link = generatedevicelink($interface);
$type = humanmedia($interface['ifType']);
echo("<tr bgcolor=$row_colour><td><a href='' class=list-bold>$dev_link</a></td><td class=list-bold>$if_link</td><td>$speed</td><td>$type</td><td>" . $interface[ifAlias] . "</td></tr>\n");
echo("<tr bgcolor=$row_colour>
<td class=list-bold>" . generatedevicelink($interface) . "</td>
<td class=list-bold>" . generateiflink($interface, makeshortif(fixifname($interface['ifDescr']))) . "</td>
<td>$speed</td>
<td>$type</td>
<td>" . $interface[ifAlias] . "</td>
</tr>\n");
$row++;

View File

@@ -327,13 +327,13 @@ function fixiftype ($type) {
}
function fixifName ($inf) {
if(strstr($inf, "oopback")) { $inf = "loopback"; }
$inf = str_replace("ether", "Ether", $inf);
$inf = str_replace("gig", "Gig", $inf);
$inf = str_replace("fast", "Fast", $inf);
$inf = str_replace("ten", "Ten", $inf);
$inf = str_replace("vlan", "Vlan", $inf);
$inf = str_replace("ether", "Ether", $inf);
$inf = str_replace("loop", "Loop", $inf);
$inf = str_replace("-802.1q Vlan subif", "", $inf);
$inf = str_replace("serial", "Serial", $inf);
$inf = str_replace("-aal5 layer", " aal5", $inf);
@@ -341,10 +341,10 @@ function fixifName ($inf) {
$inf = str_replace("atm", "ATM", $inf);
$inf = str_replace("port-channel", "Port-Channel", $inf);
$inf = str_replace("dial", "Dial", $inf);
$inf = str_replace("hp procurve switch software Loopback interface", "Loopback Interface", $inf);
$inf = str_replace("hp procurve switch software loopback interface", "Loopback Interface", $inf);
$inf = str_replace("control plane interface", "Control Plane", $inf);
$inf = preg_replace("", "Interface \\1", $inf);
$inf = preg_replace("/^([0-9]+)$/", "Interface \\1", $inf);
$inf = str_replace("loop", "Loop", $inf);
$inf = preg_replace("/^([0-9]+)$/", "Interface \\0", $inf);
return $inf;
}

View File

@@ -14,13 +14,15 @@ while ($interface = mysql_fetch_array($interface_query)) {
$snmp_cmd .= " ifDescr." . $interface['ifIndex'] . " ifAdminStatus." . $interface['ifIndex'] . " ifOperStatus." . $interface['ifIndex'] . " ";
$snmp_cmd .= "ifAlias." . $interface['ifIndex'] . " ifSpeed." . $interface['ifIndex'] . " 1.3.6.1.2.1.10.7.2.1." . $interface['ifIndex'];
$snmp_cmd .= " ifType." . $interface['ifIndex'] . " ifMtu." . $interface['ifIndex'] . " ifPhysAddress." . $interface['ifIndex'];
$snmp_cmd .= " 1.3.6.1.4.1.9.2.2.1.1.1." . $interface['ifIndex'];
$snmp_output = trim(`$snmp_cmd`);
$snmp_output = str_replace("No Such Object available on this agent at this OID", "", $snmp_output);
$snmp_output = str_replace("No Such Instance currently exists at this OID", "", $snmp_output);
$snmp_output = str_replace("\"", "", $snmp_output);
echo("Looking at " . $interface['ifDescr'] . " on " . $device['hostname'] . "\n");
list($ifName, $ifDescr, $ifAdminStatus, $ifOperStatus, $ifAlias, $ifSpeed, $ifDuplex, $ifType, $ifMtu, $ifPhysAddress) = explode("\n", $snmp_output);
list($ifName, $ifDescr, $ifAdminStatus, $ifOperStatus, $ifAlias, $ifSpeed, $ifDuplex, $ifType, $ifMtu, $ifPhysAddress, $ifHardType) = explode("\n", $snmp_output);
$ifDescr = trim(str_replace("\"", "", $ifDescr));
if ($ifDuplex == 3) { $ifDuplex = "half"; } elseif ($ifDuplex == 2) { $ifDuplex = "full"; } else { $ifDuplex = "unknown"; }
$ifDescr = strtolower($ifDescr);
@@ -31,11 +33,6 @@ while ($interface = mysql_fetch_array($interface_query)) {
$ifPhysAddress = strtolower(str_replace("\"", "", $ifPhysAddress));
$ifPhysAddress = str_replace(" ", ":", $ifPhysAddress);
if($device['os'] == "IOS") {
$locIfHardType_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " 1.3.6.1.4.1.9.2.2.1.1.1." . $interface['ifIndex'];
$locIfHardType = trim(str_replace("\"", "", `$locIfHardType_cmd`));
}
$rrdfile = "rrd/" . $device['hostname'] . "." . $interface['ifIndex'] . ".rrd";
if(!is_file($rrdfile)) {
$woo = `rrdtool create $rrdfile \
@@ -103,6 +100,13 @@ while ($interface = mysql_fetch_array($interface_query)) {
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'MAC -> $ifPhysAddress')");
}
if ( $interface['ifHardType'] != $ifHardType && $ifHardType != "" ) {
$update .= $seperator . "`ifHardType` = '$ifHardType'";
$seperator = ", ";
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" .$interface['interface_id'] . "', NOW(), 'HW Type -> $ifHardType')");
}
if ( $interface['ifSpeed'] != $ifSpeed && $ifSpeed != "" ) {
$update .= $seperator . "`ifSpeed` = '$ifSpeed'";
$seperator = ", ";