2011-03-17 00:09:20 +00:00
< ? php
2008-04-11 08:11:28 +00:00
2010-01-13 00:23:31 +00:00
if ( $_SESSION [ 'userlevel' ] < '5' )
{
include ( " includes/error-no-perm.inc.php " );
}
else
{
2011-04-18 16:56:51 +00:00
print_optionbar_start ( '' , '' );
echo ( '<span style="font-weight: bold;">BGP</span> » ' );
if ( $_GET [ 'opta' ] == " bgp " && $_GET [ 'optb' ] == " all " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( '<a href="routing/bgp/all/' . $graphs . '/">All</a>' );
if ( $_GET [ 'opta' ] == " bgp " && $_GET [ 'optb' ] == " all " ) { echo ( " </span> " ); }
echo ( ' | ' );
if ( $_GET [ 'opta' ] == " bgp " && $_GET [ 'optb' ] == " internal " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( '<a href="routing/bgp/internal/' . $graphs . '/">Internal</a>' );
if ( $_GET [ 'opta' ] == " bgp " && $_GET [ 'optb' ] == " internal " ) { echo ( " </span> " ); }
echo ( " | " );
if ( $_GET [ 'opta' ] == " bgp " && $_GET [ 'optb' ] == " external " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( '<a href="routing/bgp/external/' . $graphs . '/">External</a>' );
if ( $_GET [ 'opta' ] == " bgp " && $_GET [ 'optb' ] == " external " ) { echo ( " </span> " ); }
echo ( " | " );
if ( $_GET [ 'opta' ] == " bgp " && $_GET [ 'optb' ] == " disabled " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( '<a href="routing/bgp/disabled/' . $graphs . '/">Disabled</a>' );
if ( $_GET [ 'opta' ] == " bgp " && $_GET [ 'optb' ] == " disabled " ) { echo ( " </span> " ); }
echo ( " | " );
if ( $_GET [ 'opta' ] == " bgp " && $_GET [ 'optb' ] == " alerts " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( '<a href="routing/bgp/alerts/' . $graphs . '/">Alerts</a>' );
if ( $_GET [ 'opta' ] == " bgp " && $_GET [ 'optb' ] == " alerts " ) { echo ( " </span> " ); }
echo ( '' );
## End BGP Menu
if ( ! isset ( $graphs )) { $graphs == " nographs " ; }
echo ( '<div style="float: right;">' );
if ( $graphs == " graphs " ) { echo ( '<span class="pagemenu-selected">' ); }
if ( ! isset ( $_GET [ 'optc' ]))
{
echo ( '<a href="routing/' . $_GET [ 'opta' ] . '/graphs/"> Graphs</a>' );
} else {
echo ( '<a href="routing/' . $_GET [ 'opta' ] . '/' . $_GET [ 'optb' ] . '/graphs/"> Graphs</a>' );
}
if ( $graphs == " graphs " )
{
echo ( '</span>' );
}
echo ( ' | ' );
if ( $graphs == " nographs " )
{
echo ( '<span class="pagemenu-selected">' );
}
if ( ! isset ( $_GET [ 'optc' ]))
{
echo ( '<a href="routing/' . $_GET [ 'opta' ] . '/nographs/"> No Graphs</a>' );
} else {
echo ( '<a href="routing/' . $_GET [ 'opta' ] . '/' . $_GET [ 'optb' ] . '/nographs/"> No Graphs</a>' );
}
if ( $graphs == " nographs " )
{
echo ( '</span>' );
}
echo ( '</div>' );
print_optionbar_end ();
echo ( " <div style='margin: 5px;'> " );
echo ( " <table border=0 cellspacing=0 cellpadding=5 width=100% class='sortable'> " );
2010-11-20 14:04:07 +00:00
echo ( '<tr style="height: 30px"><td width=1></td><th>Local address</th><th></th><th>Peer address</th><th>Type</th><th>Remote AS</th><th>State</th><th>Uptime</th></tr>' );
2010-01-10 14:55:28 +00:00
2010-01-13 00:23:31 +00:00
$i = " 1 " ;
2008-04-11 08:11:28 +00:00
2011-04-17 17:22:46 +00:00
if ( $_GET [ 'optb' ] == " alerts " )
2011-03-26 19:12:24 +00:00
{
2010-01-13 00:23:31 +00:00
$where = " AND (B.bgpPeerAdminStatus = 'start' or B.bgpPeerAdminStatus = 'running') AND B.bgpPeerState != 'established' " ;
2011-04-18 16:56:51 +00:00
} elseif ( $_GET [ 'optb' ] == " disabled " ) {
$where = " AND B.bgpPeerAdminStatus = 'stop' " ;
2011-04-17 17:22:46 +00:00
} elseif ( $_GET [ 'optb' ] == " external " ) {
2010-01-13 00:23:31 +00:00
$where = " AND D.bgpLocalAs != B.bgpPeerRemoteAs " ;
2011-04-17 17:22:46 +00:00
} elseif ( $_GET [ 'optb' ] == " internal " ) {
2010-01-13 00:23:31 +00:00
$where = " AND D.bgpLocalAs = B.bgpPeerRemoteAs " ;
}
2008-04-11 08:11:28 +00:00
2010-01-13 00:23:31 +00:00
$peer_query = mysql_query ( " select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id $where ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier " );
2011-04-06 13:54:50 +00:00
while ( $peer = mysql_fetch_assoc ( $peer_query ))
2010-02-16 00:08:06 +00:00
{
2011-04-18 11:28:42 +00:00
unset ( $alert , $bg_image );
2008-04-11 08:11:28 +00:00
2011-03-17 00:09:20 +00:00
if ( ! is_integer ( $i / 2 )) { $bg_colour = $list_colour_b ; } else { $bg_colour = $list_colour_a ; }
2008-04-11 08:11:28 +00:00
2011-04-18 16:56:51 +00:00
if ( $peer [ 'bgpPeerState' ] == " established " ) { $col = " green " ; } else { $col = " red " ; $peer [ 'alert' ] = 1 ; }
2011-03-17 00:09:20 +00:00
if ( $peer [ 'bgpPeerAdminStatus' ] == " start " || $peer [ 'bgpPeerAdminStatus' ] == " running " ) { $admin_col = " green " ; } else { $admin_col = " gray " ; }
2011-04-18 16:56:51 +00:00
if ( $peer [ 'bgpPeerAdminStatus' ] == " stop " ) { $peer [ 'alert' ] = 0 ; $peer [ 'disabled' ] = 1 ; }
2011-03-17 00:09:20 +00:00
if ( $peer [ 'bgpPeerRemoteAs' ] == $peer [ 'bgpLocalAs' ]) { $peer_type = " <span style='color: #00f;'>iBGP</span> " ; } else { $peer_type = " <span style='color: #0a0;'>eBGP</span> " ;
if ( $peer [ 'bgpPeerRemoteAS' ] >= '64512' && $peer [ 'bgpPeerRemoteAS' ] <= '65535' ) { $peer_type = " <span style='color: #f00;'>Priv eBGP</span> " ; }
2010-01-13 00:23:31 +00:00
}
2008-04-11 08:11:28 +00:00
2011-04-06 13:54:50 +00:00
$peerhost = mysql_fetch_assoc ( mysql_query ( " SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ' " . $peer [ 'bgpPeerIdentifier' ] . " ' AND I.interface_id = A.interface_id AND D.device_id = I.device_id " ));
2008-04-11 08:11:28 +00:00
2011-03-17 00:09:20 +00:00
if ( $peerhost ) { $peername = generate_device_link ( $peerhost , shorthost ( $peerhost [ 'hostname' ])); } else { unset ( $peername ); }
2008-04-11 08:11:28 +00:00
2011-04-03 17:07:17 +00:00
// display overlib graphs
$graph_type = " bgp_prefixes " ;
$local_daily_url = " graph.php?id= " . $peer [ 'bgpPeer_id' ] . " &type= " . $graph_type . " &from= $day &to= $now &width=500&height=150&&afi=ipv4&safi=unicast " ;
2011-04-18 11:50:49 +00:00
$localaddresslink = " <span class=list-large><a href='device/ " . $peer [ 'device_id' ] . " /routing/bgp/prefixes/ipv4.unicast/' onmouseover= \" return overlib('<img src= \ ' $local_daily_url\ '>', LEFT " . $config [ 'overlib_defaults' ] . " ); \" onmouseout= \" return nd(); \" > " . $peer [ 'bgpLocalAddr' ] . " </a></span> " ;
2011-04-03 17:07:17 +00:00
$graph_type = " bgp_updates " ;
$peer_daily_url = " graph.php?id= " . $peer [ 'bgpPeer_id' ] . " &type= " . $graph_type . " &from= $day &to= $now &width=500&height=150 " ;
2011-04-18 11:50:49 +00:00
$peeraddresslink = " <span class=list-large><a href='device/ " . $peer [ 'device_id' ] . " /routing/bgp/updates/' onmouseover= \" return overlib('<img src= \ ' $peer_daily_url\ '>', LEFT " . $config [ 'overlib_defaults' ] . " ); \" onmouseout= \" return nd(); \" > " . $peer [ 'bgpPeerIdentifier' ] . " </a></span> " ;
2011-04-03 17:07:17 +00:00
2011-04-18 16:56:51 +00:00
echo ( '<tr bgcolor="' . $bg_colour . '"' . ( $peer [ 'alert' ] ? ' bordercolor="#cc0000"' : '' ) .
( $peer [ 'disabled' ] ? ' bordercolor="#cccccc"' : '' ) . " >
2010-02-08 18:07:00 +00:00
< td ></ td >
2011-04-18 11:50:49 +00:00
< td width = 150 > " . $localaddresslink . " < br /> " .generate_device_link( $peer , shorthost( $peer['hostname'] ), 'routing/bgp/'). " </ td >
2008-09-25 13:54:58 +00:00
< td width = 30 >-></ td >
2011-04-03 17:07:17 +00:00
< td width = 150 > " . $peeraddresslink . " </ td >
2008-04-13 16:27:05 +00:00
< td width = 50 >< b > $peer_type </ b ></ td >
2010-01-13 00:23:31 +00:00
< td >< strong > AS " . $peer['bgpPeerRemoteAs'] . " </ strong >< br /> " . $peer['astext'] . " </ td >
2011-03-28 09:11:05 +00:00
< td >< strong >< span style = 'color: $admin_col;' > " . $peer['bgpPeerAdminStatus'] . " </ span >< br />< span style = 'color: $col;' > " . $peer['bgpPeerState'] . " </ span ></ strong ></ td >
2010-01-13 00:23:31 +00:00
< td > " .formatUptime( $peer['bgpPeerFsmEstablishedTime'] ). " < br />
2011-03-28 09:11:05 +00:00
Updates < img src = 'images/16/arrow_down.png' align = absmiddle /> " . format_si( $peer['bgpPeerInUpdates'] ) . "
< img src = 'images/16/arrow_up.png' align = absmiddle /> " . format_si( $peer['bgpPeerOutUpdates'] ) . " </ td ></ tr > " );
2010-01-13 00:23:31 +00:00
2008-04-11 08:11:28 +00:00
2011-04-18 11:28:42 +00:00
if ( $graphs == " graphs " )
{
$graph_array [ 'height' ] = " 100 " ;
$graph_array [ 'width' ] = " 215 " ;
$graph_array [ 'to' ] = $now ;
$graph_array [ 'id' ] = $peer [ 'bgpPeer_id' ];
$graph_array [ 'type' ] = " bgp_updates " ;
2008-04-11 08:11:28 +00:00
2011-04-18 11:28:42 +00:00
echo ( '<tr bgcolor="' . $bg_colour . '"' . ( $bg_image ? ' background="' . $bg_image . '"' : '' ) . '"><td colspan="8">' );
2008-04-11 08:11:28 +00:00
2011-04-18 11:28:42 +00:00
include ( " includes/print-quadgraphs.inc.php " );
2008-04-11 08:11:28 +00:00
2010-01-13 00:23:31 +00:00
echo ( " </td></tr> " );
}
2008-04-11 08:11:28 +00:00
2010-01-13 00:23:31 +00:00
$i ++ ;
}
2011-03-17 00:09:20 +00:00
2010-01-13 00:23:31 +00:00
echo ( " </table></div> " );
}
2011-03-17 00:09:20 +00:00
2011-03-19 01:43:13 +00:00
?>