2009-09-24 14:38:17 +00:00
< div style = 'padding: 10px; height: 20px; clear: both; display: block;' >
2011-03-31 10:51:02 +00:00
< div style = 'float: left; font-size: 22px; font-weight: bold;' > Local AS : < ? php echo ( $device [ 'bgpLocalAs' ]); ?> </div>
2010-11-25 15:32:47 +00:00
</ div >
2009-09-24 14:38:17 +00:00
2010-11-25 15:32:47 +00:00
< ? php
2010-01-09 17:37:51 +00:00
print_optionbar_start ();
2010-11-25 15:32:47 +00:00
2011-04-19 21:54:43 +00:00
echo ( " <span style='font-weight: bold;'>BGP</span> » " );
2011-03-16 23:10:10 +00:00
2011-04-17 16:14:44 +00:00
if ( ! isset ( $_GET [ 'optb' ])) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( " <a href='/device/ " . $device [ 'device_id' ] . " /routing/bgp/'>Basic</a> " );
if ( ! isset ( $_GET [ 'optb' ])) { echo ( " </span> " ); }
2010-11-25 15:32:47 +00:00
2011-04-17 16:14:44 +00:00
echo ( " | " );
if ( $_GET [ 'optb' ] == " updates " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( " <a href='/device/ " . $device [ 'device_id' ] . " /routing/bgp/updates/'>Updates</a> " );
if ( $_GET [ 'optb' ] == " updates " ) { echo ( " </span> " ); }
echo ( " | Prefixes: " );
if ( $_GET [ 'optb' ] == " prefixes " && $_GET [ 'optc' ] == " ipv4.unicast " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( " <a href=' " . $config [ 'base_url' ] . " /device/ " . $device [ 'device_id' ] . " /routing/bgp/prefixes/ipv4.unicast/'>IPv4</a> " );
if ( $_GET [ 'optb' ] == " prefixes " && $_GET [ 'optc' ] == " ipv4.unicast " ) { echo ( " </span> " ); }
echo ( " | " );
if ( $_GET [ 'optb' ] == " prefixes " && $_GET [ 'optc' ] == " vpnv4.unicast " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( " <a href=' " . $config [ 'base_url' ] . " /device/ " . $device [ 'device_id' ] . " /routing/bgp/prefixes/vpnv4.unicast/'>VPNv4</a> " );
if ( $_GET [ 'optb' ] == " prefixes " && $_GET [ 'optc' ] == " vpnv4.unicast " ) { echo ( " </span> " ); }
echo ( " | " );
if ( $_GET [ 'optb' ] == " prefixes " && $_GET [ 'optc' ] == " ipv6.unicast " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( " <a href=' " . $config [ 'base_url' ] . " /device/ " . $device [ 'device_id' ] . " /routing/bgp/prefixes/ipv6.unicast/'>IPv6</a> " );
if ( $_GET [ 'optb' ] == " prefixes " && $_GET [ 'optc' ] == " ipv6.unicast " ) { echo ( " </span> " ); }
echo ( " | Traffic: " );
if ( $_GET [ 'optb' ] == " macaccounting " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( " <a href=' " . $config [ 'base_url' ] . " /device/ " . $device [ 'device_id' ] . " /routing/bgp/macaccounting/'>Mac Accounting</a> " );
if ( $_GET [ 'optb' ] == " macaccounting " ) { echo ( " </span> " ); }
2010-11-25 15:32:47 +00:00
2010-01-09 17:37:51 +00:00
print_optionbar_end ();
2009-01-07 12:37:18 +00:00
2011-04-19 21:54:43 +00:00
echo ( '<table border="0" cellspacing="0" cellpadding="5" width="100%">' );
echo ( '<tr style="height: 30px"><td width=1></td><th></th><th>Peer address</th><th>Type</th><th>Remote AS</th><th>State</th><th>Uptime</th></tr>' );
2010-11-25 15:32:47 +00:00
$i = " 1 " ;
$peer_query = mysql_query ( " select * from bgpPeers WHERE device_id = ' " . $device [ 'device_id' ] . " ' ORDER BY bgpPeerRemoteAs, bgpPeerIdentifier " );
2011-03-16 23:10:10 +00:00
2010-11-25 15:32:47 +00:00
while ( $peer = mysql_fetch_assoc ( $peer_query ))
{
$has_macaccounting = mysql_result ( mysql_query ( " SELECT COUNT(*) FROM `ipv4_mac` AS I, mac_accounting AS M WHERE I.ipv4_address = ' " . $peer [ 'bgpPeerIdentifier' ] . " ' AND M.mac = I.mac_address " ), 0 );
unset ( $bg_image );
if ( ! is_integer ( $i / 2 )) { $bg_colour = $list_colour_a ; } else { $bg_colour = $list_colour_b ; }
2011-04-19 21:54:43 +00:00
unset ( $alert , $bg_image );
if ( ! is_integer ( $i / 2 )) { $bg_colour = $list_colour_b ; } else { $bg_colour = $list_colour_a ; }
if ( $peer [ 'bgpPeerState' ] == " established " ) { $col = " green " ; } else { $col = " red " ; $peer [ 'alert' ] = 1 ; }
if ( $peer [ 'bgpPeerAdminStatus' ] == " start " || $peer [ 'bgpPeerAdminStatus' ] == " running " ) { $admin_col = " green " ; } else { $admin_col = " gray " ; }
if ( $peer [ 'bgpPeerAdminStatus' ] == " stop " ) { $peer [ 'alert' ] = 0 ; $peer [ 'disabled' ] = 1 ; }
2010-11-25 15:32:47 +00:00
if ( $peer [ 'bgpPeerRemoteAs' ] == $device [ 'bgpLocalAs' ]) { $peer_type = " <span style='color: #00f;'>iBGP</span> " ; } else { $peer_type = " <span style='color: #0a0;'>eBGP</span> " ; }
$query = " SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE " ;
$query .= " (A.ipv4_address = ' " . $peer [ 'bgpPeerIdentifier' ] . " ' AND I.interface_id = A.interface_id) " ;
$query .= " AND D.device_id = I.device_id " ;
$ipv4_host = mysql_fetch_assoc ( mysql_query ( $query ));
$query = " SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE " ;
$query .= " (A.ipv6_address = ' " . $peer [ 'bgpPeerIdentifier' ] . " ' AND I.interface_id = A.interface_id) " ;
$query .= " AND D.device_id = I.device_id " ;
$ipv6_host = mysql_fetch_assoc ( mysql_query ( $query ));
if ( $ipv4_host )
{
$peerhost = $ipv4_host ;
}
elseif ( $ipv6_host )
{
$peerhost = $ipv6_host ;
}
else
{
unset ( $peerhost );
}
if ( $peerhost )
{
$peername = generate_device_link ( $peerhost );
}
else
{
2011-04-17 16:14:44 +00:00
#$peername = gethostbyaddr($peer['bgpPeerIdentifier']); ## FFffuuu DNS
2010-11-25 15:32:47 +00:00
if ( $peername == $peer [ 'bgpPeerIdentifier' ])
{
unset ( $peername );
} else {
$peername = " <i> " . $peername . " <i> " ;
2010-01-27 21:51:59 +00:00
}
2010-11-25 15:32:47 +00:00
}
$af_query = mysql_query ( " SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ' " . $device [ 'device_id' ] . " ' AND bgpPeerIdentifier = ' " . $peer [ 'bgpPeerIdentifier' ] . " ' " );
unset ( $peer_af );
while ( $afisafi = mysql_fetch_assoc ( $af_query ))
{
$afi = $afisafi [ 'afi' ];
$safi = $afisafi [ 'safi' ];
$peer_af .= $sep . $config [ 'afi' ][ $afi ][ $safi ]; ##### CLEAN ME UP, I AM MESSY AND I SMELL OF CHEESE!
$sep = " <br /> " ;
$valid_afi_safi [ $afi ][ $safi ] = 1 ; ## Build a list of valid AFI/SAFI for this peer
}
2008-03-15 17:58:15 +00:00
2010-11-25 15:32:47 +00:00
unset ( $sep );
2011-04-03 17:17:14 +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-17 15:55:38 +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:17:14 +00:00
2011-04-19 21:54:43 +00:00
echo ( '<tr bgcolor="' . $bg_colour . '"' . ( $peer [ 'alert' ] ? ' bordercolor="#cc0000"' : '' ) .
( $peer [ 'disabled' ] ? ' bordercolor="#cccccc"' : '' ) . " >
" );
echo ( " <td width=20><span class=list-large> " . $i . " </span></td>
2011-04-03 17:17:14 +00:00
< td > " . $peeraddresslink . " < br /> " .generate_device_link( $peer , shorthost( $peer['hostname'] ), 'bgp/'). " </ td >
2008-03-18 13:35:17 +00:00
< td > $peer_type </ td >
2010-11-25 15:32:47 +00:00
< td style = 'font-size: 10px; font-weight: bold; line-height: 10px;' > " . (isset( $peer_af ) ? $peer_af : '') . " </ td >
< td >< strong > AS " . $peer['bgpPeerRemoteAs'] . " </ strong >< br /> " . $peer['astext'] . " </ td >
< td >< strong >< span style = 'color: $admin_col;' > " . $peer['bgpPeerAdminStatus'] . " < span >< br />< span style = 'color: $col;' > " . $peer['bgpPeerState'] . " </ span ></ strong ></ td >
< td > " .formatUptime( $peer['bgpPeerFsmEstablishedTime'] ). " < br />
Updates < img src = 'images/16/arrow_down.png' align = absmiddle > " . $peer['bgpPeerInUpdates'] . "
2011-04-19 21:54:43 +00:00
< img src = 'images/16/arrow_up.png' align = absmiddle > " . $peer['bgpPeerOutUpdates'] . " </ td >
</ tr > " );
2010-11-25 15:32:47 +00:00
2011-04-19 21:54:43 +00:00
if ( $_GET [ 'optb' ] != " basic " && isset ( $_GET [ 'optb' ]) && $_GET [ 'optb' ] != " macaccounting " )
2010-11-25 15:32:47 +00:00
{
2011-04-19 21:54:43 +00:00
unset ( $graph_array );
2011-04-17 15:55:38 +00:00
foreach ( explode ( " " , $_GET [ 'optb' ]) as $graph_type )
2011-03-16 23:10:10 +00:00
{
2011-04-19 21:54:43 +00:00
if ( $graph_type == " prefixes " )
{
$graph_array [ 'type' ] = " bgp_prefixes " ;
list ( $afi , $safi ) = explode ( " . " , $_GET [ 'optc' ]);
$graph_array [ 'afi' ] = $afi ;
$graph_array [ 'safi' ] = $safi ;
} else {
$graph_array [ 'type' ] = " bgp_updates " ;
}
$graph_array [ 'height' ] = " 100 " ;
$graph_array [ 'width' ] = " 215 " ;
$graph_array [ 'to' ] = $now ;
$graph_array [ 'id' ] = $peer [ 'bgpPeer_id' ];
if ( $graph_type == " updates " || $valid_afi_safi [ $afi ][ $safi ])
2010-11-25 15:32:47 +00:00
{
2011-04-19 21:54:43 +00:00
echo ( '<tr bgcolor="' . $bg_colour . '"><td colspan="7">' );
include ( " includes/print-quadgraphs.inc.php " );
2010-02-08 16:21:40 +00:00
echo ( " </td></tr> " );
2011-04-19 21:54:43 +00:00
}
2010-02-08 16:21:40 +00:00
}
2011-04-19 21:54:43 +00:00
2010-02-08 16:21:40 +00:00
}
2010-11-29 11:14:01 +00:00
2011-03-16 23:10:10 +00:00
if ( $_GET [ 'opta' ] == " macaccounting " && $has_macaccounting )
2010-11-25 15:32:47 +00:00
{
$acc = mysql_fetch_assoc ( mysql_query ( " SELECT * FROM `ipv4_mac` AS I, mac_accounting AS M, ports AS P WHERE I.ipv4_address = ' " . $peer [ 'bgpPeerIdentifier' ] . " ' AND M.mac = I.mac_address AND P.interface_id = M.interface_id " ));
$graph_type = " mac_acc_bits " ;
$database = $config [ 'rrd_dir' ] . " / " . $device [ 'hostname' ] . " /cip- " . $acc [ 'ifIndex' ] . " - " . $acc [ 'mac' ] . " .rrd " ;
2011-03-16 23:10:10 +00:00
if ( is_file ( $database ))
2010-11-25 15:32:47 +00:00
{
2011-04-19 21:54:43 +00:00
$graph_array [ 'graph_type' ] = $graph_type ;
$graph_array [ 'height' ] = " 100 " ;
$graph_array [ 'width' ] = " 215 " ;
$graph_array [ 'to' ] = $now ;
$graph_array [ 'id' ] = $acc [ 'ma_id' ];
echo ( '<tr bgcolor="' . $bg_colour . '"><td colspan="8">' );
include ( " includes/print-quadgraphs.inc.php " );
2010-11-25 15:32:47 +00:00
echo ( " </td></tr> " );
2011-04-19 21:54:43 +00:00
2010-02-08 16:21:40 +00:00
}
}
2010-11-25 15:32:47 +00:00
2010-02-08 16:21:40 +00:00
$i ++ ;
2010-11-29 11:14:01 +00:00
unset ( $valid_afi_safi );
2009-06-10 05:42:48 +00:00
}
2008-03-15 17:58:15 +00:00
?>
2010-11-25 15:32:47 +00:00
2011-04-19 21:54:43 +00:00
</ table >