new things!

git-svn-id: http://www.observium.org/svn/observer/trunk@255 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2008-10-28 18:25:53 +00:00
parent de46eb01e9
commit e66aad0333
6 changed files with 61 additions and 6 deletions

View File

@@ -38,7 +38,9 @@ while ($device = mysql_fetch_array($device_query)) {
# include("includes/discovery/unix-memory.php");
include("cisco-vrf.php");
include("cisco-pw.php");
# include("cisco-vrf.php");
echo("\n"); $devices_polled++;
}

View File

@@ -57,6 +57,7 @@ while ($device = mysql_fetch_array($device_query)) {
include("includes/discovery/cisco-vlans.php");
include("includes/discovery/cisco-physical.php");
include("includes/discovery/bgp-peers.php");
include("includes/discovery/cisco-pw.php");
}
echo("\n"); $devices_polled++;

View File

@@ -25,13 +25,15 @@
$graph_url = "graph.php?if=$if_id&from=$twoday&to=$now&width=400&height=120&type=bits";
echo("<tr style=\"background-color: $bg; padding: 5px;\" valign=top>
<td valign=top width=300>
<span class=list-large>
<td valign=top width=300>");
echo(" <span class=list-large>
" . generateiflink($interface, "$i. $ifDescr") . " $error_img
</span><br /><span class=interface-desc>$ifAlias</span>");
if($ifAlias) { echo("<br />"); }
if($ifAlias) { echo("<br />"); }
unset ($break);
if(!$dographs) {
@@ -176,6 +178,17 @@ echo("</td>");
}
$pseudowires = mysql_query("SELECT * FROM `pseudowires` WHERE `interface_id` = '" . $interface['interface_id'] . "'");
while($pseudowire = mysql_fetch_array($pseudowires)) {
#`interface_id`,`peer_device_id`,`peer_ldp_id`,`cpwVcID`,`cpwOid`
$pw_peer_dev = mysql_fetch_array(mysql_query("SELECT * from `devices` WHERE `device_id` = '" . $pseudowire['peer_device_id'] . "'"));
$pw_peer_int = mysql_fetch_array(mysql_query("SELECT * from `interfaces` AS I, pseudowires AS P WHERE I.device_id = '".$pseudowire['peer_device_id']."' AND
P.cpwVcID = '".$pseudowire['cpwVcID']."' AND
P.interface_id = I.interface_id"));
echo("<img src='images/16/arrow_switch.png' align=absmiddle><b> " . generateiflink($pw_peer_int, makeshortif($pw_peer_int['ifDescr'])) ." on ". generatedevicelink($pw_peer_dev) . "</b>");
}
echo("</td></tr>");
// If we're showing graphs, generate the graph and print the img tags

View File

@@ -37,6 +37,7 @@
echo("<li><a href='syslog/'><img src='images/16/page.png' border=0 align=absmiddle> Syslog</a></li>");
} ?>
<li><a href="alerts/"><img src='images/16/exclamation.png' border=0 align=absmiddle> Alerts</a></li>
<li><a href="inventory/"><img src='images/16/bricks.png' border=0 align=absmiddle> Inventory</a></li>
</ul>
</td></tr></table>
<!--[if lte IE 6]></a><![endif]-->

38
includes/discovery/cisco-pw.php Executable file
View File

@@ -0,0 +1,38 @@
<?php
unset( $cpw_count );
echo("PW : ");
$oids = shell_exec($config['snmpwalk'] . " -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " cpwVcID");
$oids = str_replace(".1.3.6.1.4.1.9.10.106.1.2.1.10.", "", $oids);
$oids = trim($oids);
foreach ( explode("\n", $oids) as $oid ) {
if($oid) {
list($cpwOid, $cpwVcID) = explode(" ", $oid);
if($cpwOid) {
list($cpw_remote_id) = split(":", shell_exec($config['snmpget'] . " -Ln -Osqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " cpwVcMplsPeerLdpID." . $cpwOid));
$interface_descr = trim(shell_exec("snmpwalk -Oqvn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " cpwVcName." . $cpwOid));
$cpw_remote_device = @mysql_result(mysql_query("SELECT device_id FROM ipaddr AS A, interfaces AS I WHERE A.addr = '".$cpw_remote_id."' AND A.interface_id = I.interface_id"),0);
$if_id = @mysql_result(mysql_query("SELECT `interface_id` FROM `interfaces` WHERE `ifDescr` = '$interface_descr' AND `device_id` = '".$device['device_id']."'"),0);
if($cpw_remote_device && $if_id) {
$hostname = gethostbyid($cpw_remote_device);
echo("Oid: " . $cpwOid . " cpwVcID: " . $cpwVcID . " Remote Id: " . $cpw_remote_id . "($hostname(".$cpw_remote_device.") -> $interface_descr($if_id)) \n");
if(mysql_result(mysql_query("SELECT count(*) FROM pseudowires WHERE `interface_id` = '$if_id'
AND `cpwVcID`='".$cpwVcID."'"),0)) {
echo("already have! \n");
} else {
$insert_query = "INSERT INTO `pseudowires` (`interface_id`,`peer_device_id`,`peer_ldp_id`,`cpwVcID`,`cpwOid`) ";
$insert_query .= "VALUES ('$if_id','$cpw_remote_device','$cpw_remote_id','$cpwVcID', '$cpwOid')";
mysql_query($insert_query);
}
}
}
}
}
?>

View File

@@ -273,7 +273,7 @@ function generatedevicelink($device, $text=0, $start=0, $end=0) {
if(!$end) { $end = $now; }
$class = devclass($device);
if(!$text) { $text = $device['hostname']; }
$graph_url = "graph.php?host=" . $device[device_id] . "&from=$start&to=$end&width=400&height=120&type=cpu";
$graph_url = "graph.php?host=" . $device['device_id'] . "&from=$start&to=$end&width=400&height=120&type=cpu";
$link = "<a class=$class href='?page=device&id=" . $device['device_id'] . "' ";
$link .= "onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - CPU Load</div>";
$link .= "<img src=\'$graph_url\'>'".$config['overlib_defaults'].", LEFT);\" onmouseout=\"return nd();\">$text</a>";
@@ -551,7 +551,7 @@ function fixiftype ($type) {
}
function fixifName ($inf) {
if(strstr($inf, "oopback")) { $inf = "loopback"; }
#if(strstr($inf, "oopback")) { $inf = "loopback"; }
$inf = str_replace("ether", "Ether", $inf);
$inf = str_replace("gig", "Gig", $inf);
$inf = str_replace("fast", "Fast", $inf);