Add BGP detection and polling. Fix a lot of other things.

git-svn-id: http://www.observium.org/svn/observer/trunk@161 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2008-03-15 17:58:15 +00:00
parent 935744d1ed
commit 190f5ee2ce
15 changed files with 259 additions and 57 deletions
+8
View File
@@ -22,7 +22,11 @@
} elseif($_GET['if']) {
$device_id = getifhost($_GET['if']);
$ifIndex = getifindexbyid($_GET['if']);
} elseif($_GET['peer']) {
$device_id = getpeerhost($_GET['peer']);
}
if($device_id) {
$hostname = gethostbyid($device_id);
}
@@ -71,6 +75,10 @@
case 'unixfs':
$graph = unixfsgraph ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'bgpupdates':
$bgpPeerIdentifier = mysql_result(mysql_query("SELECT bgpPeerIdentifier FROM bgpPeers WHERE bgpPeer_id = '".$_GET['peer']."'"),0);
$graph = bgpupdatesgraph ($hostname . "/bgp-" . $bgpPeerIdentifier . ".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'calls':
$graph = callsgraphSNOM ($hostname . "/data.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
+5 -5
View File
@@ -28,11 +28,11 @@ if($_GET[debug]) {
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title><?php echo("$page_title"); ?></title>
<base href="<?php echo("$base_url"); ?>" />
<base href="<?php echo($config['base_url']); ?>" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- <meta http-equiv="refresh" content="300"> -->
<link href="<?php echo($stylesheet); ?>" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="<?php echo($favicon); ?>" />
<link href="<?php echo($config['stylesheet']); ?>" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="<?php echo($config['favicon']); ?>" />
<link rel="stylesheet" href="css/mktree.css" type="text/css">
</head>
<script type="text/javascript" src="js/mktree.js"></script>
@@ -55,7 +55,7 @@ function popUp(URL) {
<td align=right>
<?
if($_SESSION['authenticated']) {
echo("Logged in as <b>$_SESSION[username]</b> (<a href='?logout=yes'>Logout</a>)");
echo("Logged in as <b>".$_SESSION['username']."</b> (<a href='?logout=yes'>Logout</a>)");
} else {
echo("Not logged in!");
}
@@ -68,7 +68,7 @@ function popUp(URL) {
<table width="100%" style="padding: 0px; margin:0px;">
<tr>
<td style="padding: 0px; margin:0px; border: none;">
<div id=logo style="padding: 10px"><a href="index.php"><img src="<?php echo("$title_image"); ?>" border="0" /></a></div>
<div id=logo style="padding: 10px"><a href="index.php"><img src="<?php echo($config['title_image']); ?>" border="0" /></a></div>
</td>
<td align=right style="margin-right: 10px;">
<div id="topnav" style="float: right;">
+9
View File
@@ -36,6 +36,15 @@ if(@mysql_result(mysql_query("select count(vlan_id) from vlans WHERE device_id =
</li>");
}
if($device['bgpLocalAs']) {
echo("
<li class=" . $select['dev-bgp'] . ">
<a href='?page=device&id=" . $device['device_id'] . "&section=dev-bgp' >
<img src='images/16/link.png' align=absmiddle border=0> BGP
</a>
</li>");
}
if(@mysql_result(mysql_query("select count(interface_id) from interfaces WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
echo("
<li class=" . $select['dev-ifs'] . ">
+56
View File
@@ -0,0 +1,56 @@
<?php
echo("<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$i = "1";
$peer_query = mysql_query("select * from bgpPeers WHERE device_id = '".$device['device_id']."' ORDER BY bgpPeerRemoteAs, bgpPeerIdentifier");
while($peer = mysql_fetch_array($peer_query)) {
if(!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
if($peer['bgpPeerAdminStatus'] == "start") { $img = "images/16/accept.png"; } else { $img = "images/16/delete.png"; }
if($peer['bgpPeerState'] == "established") { $col = "green"; } else { $col = "red"; $bg_colour = "#fcc"; }
$peerhost = mysql_fetch_array(mysql_query("SELECT * FROM ipaddr AS A, interfaces AS I, devices AS D WHERE A.addr = '".$peer['bgpPeerIdentifier']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id"));
if($peerhost) { $peername = generatedevicelink($peerhost); } else { unset($peername); }
echo("<tr bgcolor=$bg_colour><th>$i</td><td><span class=list-large>" . $peer['bgpPeerIdentifier'] . "</span><br />".$peername."</td><td>AS" . $peer['bgpPeerRemoteAs'] . "<br />" . $peer['astext'] . "</td><td><img src='$img'></td><td><span style='color: $col;'>" . $peer['bgpPeerState'] . "</span></td><td>" .formatUptime($peer['bgpPeerFsmEstablishedTime']). "</td></tr>");
# if($graphs) {
$graph_type = "bgpupdates";
$daily_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=210&height=100";
$daily_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150";
$weekly_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=210&height=100";
$weekly_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$week&to=$now&width=500&height=150";
$monthly_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=210&height=100";
$monthly_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$month&to=$now&width=500&height=150";
$yearly_traffic = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=210&height=100";
$yearly_url = "graph.php?peer=" . $peer['bgpPeer_id'] . "&type=$graph_type&from=$year&to=$now&width=500&height=150";
echo("<tr><td colspan=6>");
echo("<a href='?page=interface&id=" . $peer['bgpPeer_id'] . "' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">
<img src='$daily_traffic' border=0></a> ");
echo("<a href='?page=interface&id=" . $peer['bgpPeer_id'] . "' onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">
<img src='$weekly_traffic' border=0></a> ");
echo("<a href='?page=interface&id=" . $peer['bgpPeer_id'] . "' onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\">
<img src='$monthly_traffic' border=0></a> ");
echo("<a href='?page=interface&id=" . $peer['bgpPeer_id'] . "' onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT".$config['overlib_defaults'].", WIDTH, 350);\" onmouseout=\"return nd();\">
<img src='$yearly_traffic' border=0></a>");
echo("</td></tr>");
# }
$i++;
}
echo("</table></div>");
?>
+2
View File
@@ -1,5 +1,7 @@
<?php
if (isset($_GET["dir"])) {
$dir = $_GET["dir"];
} else {