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
2011-09-19 08:54:48 +00:00
$link_array = array ( 'page' => 'device' ,
'device' => $device [ 'device_id' ],
'tab' => 'routing' ,
'proto' => 'bgp' );
if ( ! isset ( $vars [ 'view' ])) { $vars [ 'view' ] = " basic " ; }
2010-01-09 17:37:51 +00:00
print_optionbar_start ();
2010-11-25 15:32:47 +00:00
2011-05-01 20:29:31 +00:00
echo ( " <span style='font-weight: bold;'>BGP</span> » " );
2011-03-16 23:10:10 +00:00
2011-09-19 08:54:48 +00:00
if ( $vars [ 'view' ] == " basic " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( generate_link ( " Basic " , $link_array , array ( 'view' => 'basic' )));
if ( $vars [ 'view' ] == " basic " ) { echo ( " </span> " ); }
2010-11-25 15:32:47 +00:00
2011-05-01 20:29:31 +00:00
echo ( " | " );
2011-04-17 16:14:44 +00:00
2011-09-19 08:54:48 +00:00
if ( $vars [ 'view' ] == " updates " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( generate_link ( " Updates " , $link_array , array ( 'view' => 'updates' )));
if ( $vars [ 'view' ] == " updates " ) { echo ( " </span> " ); }
2011-04-17 16:14:44 +00:00
2011-05-01 20:29:31 +00:00
echo ( " | Prefixes: " );
2011-04-17 16:14:44 +00:00
2011-09-19 08:54:48 +00:00
if ( $vars [ 'view' ] == " prefixes_ipv4unicast " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( generate_link ( " IPv4 " , $link_array , array ( 'view' => 'prefixes_ipv4unicast' )));
if ( $vars [ 'view' ] == " prefixes_ipv4unicast " ) { echo ( " </span> " ); }
2011-04-17 16:14:44 +00:00
2011-05-01 20:29:31 +00:00
echo ( " | " );
2011-04-17 16:14:44 +00:00
2011-09-19 08:54:48 +00:00
if ( $vars [ 'view' ] == " prefixes_vpnv4unicast " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( generate_link ( " VPNv4 " , $link_array , array ( 'view' => 'prefixes_vpnv4unicast' )));
if ( $vars [ 'view' ] == " prefixes_vpnv4unicast " ) { echo ( " </span> " ); }
2011-04-17 16:14:44 +00:00
2011-05-01 20:29:31 +00:00
echo ( " | " );
2011-04-17 16:14:44 +00:00
2011-09-19 08:54:48 +00:00
if ( $vars [ 'view' ] == " prefixes_ipv6unicast " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( generate_link ( " IPv6 " , $link_array , array ( 'view' => 'prefixes_ipv6unicast' )));
if ( $vars [ 'view' ] == " prefixes_ipv6unicast " ) { echo ( " </span> " ); }
2011-04-17 16:14:44 +00:00
2011-05-01 20:29:31 +00:00
echo ( " | Traffic: " );
2011-04-29 17:11:07 +00:00
2011-09-19 08:54:48 +00:00
if ( $vars [ 'view' ] == " macaccounting_bits " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( generate_link ( " Bits " , $link_array , array ( 'view' => 'macaccounting_bits' )));
if ( $vars [ 'view' ] == " macaccounting_bits " ) { echo ( " </span> " ); }
2011-05-01 20:29:31 +00:00
echo ( " | " );
2011-09-19 08:54:48 +00:00
if ( $vars [ 'view' ] == " macaccounting_pkts " ) { echo ( " <span class='pagemenu-selected'> " ); }
echo ( generate_link ( " Packets " , $link_array , array ( 'view' => 'macaccounting_pkts' )));
if ( $vars [ 'view' ] == " macaccounting_pkts " ) { 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 " ;
2011-03-16 23:10:10 +00:00
2011-05-16 10:44:50 +00:00
foreach ( dbFetchRows ( " SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `bgpPEerRemoteAs`, `bgpPeerIdentifier` " , array ( $device [ 'device_id' ])) as $peer )
2010-11-25 15:32:47 +00:00
{
2011-05-16 10:44:50 +00:00
$has_macaccounting = dbFetchCell ( " SELECT COUNT(*) FROM `ipv4_mac` AS I, mac_accounting AS M WHERE I.ipv4_address = ? AND M.mac = I.mac_address " , array ( $peer [ 'bgpPeerIdentifier' ]));
2010-11-25 15:32:47 +00:00
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 );
2012-02-17 16:46:28 +00:00
unset ( $peerhost , $peername );
2011-04-19 21:54:43 +00:00
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 " ;
2012-05-16 13:25:50 +00:00
$query .= " (A.ipv4_address = ? AND I.port_id = A.port_id) " ;
2010-11-25 15:32:47 +00:00
$query .= " AND D.device_id = I.device_id " ;
2011-05-16 10:44:50 +00:00
$ipv4_host = dbFetchRow ( $query , array ( $peer [ 'bgpPeerIdentifier' ]));
2010-11-25 15:32:47 +00:00
$query = " SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE " ;
2012-05-16 13:25:50 +00:00
$query .= " (A.ipv6_address = ? AND I.port_id = A.port_id) " ;
2010-11-25 15:32:47 +00:00
$query .= " AND D.device_id = I.device_id " ;
2011-05-16 10:44:50 +00:00
$ipv6_host = dbFetchRow ( $query , array ( $peer [ 'bgpPeerIdentifier' ]));
2010-11-25 15:32:47 +00:00
if ( $ipv4_host )
{
$peerhost = $ipv4_host ;
2011-05-01 20:29:31 +00:00
} elseif ( $ipv6_host ) {
2010-11-25 15:32:47 +00:00
$peerhost = $ipv6_host ;
2011-05-01 20:29:31 +00:00
} else {
2010-11-25 15:32:47 +00:00
unset ( $peerhost );
}
2012-02-27 23:36:19 +00:00
if ( is_array ( $peerhost ))
2010-11-25 15:32:47 +00:00
{
2012-02-27 23:36:19 +00:00
#$peername = generate_device_link($peerhost);
2011-11-17 14:19:21 +00:00
$peername = generate_device_link ( $peerhost ) . " " . generate_port_link ( $peerhost );
2012-02-17 16:46:28 +00:00
$peer_url = " device/device= " . $peer [ 'device_id' ] . " /tab=routing/proto=bgp/view=updates/ " ;
2010-11-25 15:32:47 +00:00
}
else
{
2012-05-25 12:24:34 +00:00
#$peername = gethostbyaddr($peer['bgpPeerIdentifier']); // FFffuuu DNS // Cache this in discovery?
2012-02-17 16:46:28 +00:00
# if ($peername == $peer['bgpPeerIdentifier'])
# {
# unset($peername);
# } else {
# $peername = "<i>".$peername."<i>";
# }
2010-11-25 15:32:47 +00:00
}
unset ( $peer_af );
2011-04-29 16:32:55 +00:00
unset ( $sep );
2011-05-01 20:29:31 +00:00
2011-05-16 10:44:50 +00:00
foreach ( dbFetchRows ( " SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ? " , array ( $device [ 'device_id' ], $peer [ 'bgpPeerIdentifier' ])) as $afisafi )
2010-11-25 15:32:47 +00:00
{
$afi = $afisafi [ 'afi' ];
$safi = $afisafi [ 'safi' ];
2011-04-29 17:11:07 +00:00
$this_afisafi = $afi . $safi ;
$peer [ 'afi' ] .= $sep . $afi . " . " . $safi ;
2010-11-25 15:32:47 +00:00
$sep = " <br /> " ;
2012-05-25 12:24:34 +00:00
$peer [ 'afisafi' ][ $this_afisafi ] = 1 ; // Build a list of valid AFI/SAFI for this peer
2010-11-25 15:32:47 +00:00
}
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 " ;
2012-05-06 18:38:11 +00:00
$peer_daily_url = " graph.php?id= " . $peer [ 'bgpPeer_id' ] . " &type= " . $graph_type . " &from= " . $config [ 'time' ][ 'day' ] . " &to= " . $config [ 'time' ][ 'now' ] . " &width=500&height=150 " ;
2012-02-17 16:46:28 +00:00
$peeraddresslink = " <span class=list-large><a 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-11-17 14:19:21 +00:00
< td > " . $peeraddresslink . " < br /> " . $peername . " </ td >
2011-09-20 14:37:54 +00:00
< td > $peer_type </ td >
2011-04-29 17:11:07 +00:00
< td style = 'font-size: 10px; font-weight: bold; line-height: 10px;' > " . (isset( $peer['afi'] ) ? $peer['afi'] : '') . " </ td >
2010-11-25 15:32:47 +00:00
< 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 >
2011-05-01 12:37:43 +00:00
</ tr >
< tr height = 5 ></ tr > " );
2010-11-25 15:32:47 +00:00
2011-05-01 20:29:31 +00:00
unset ( $invalid );
2011-04-19 21:54:43 +00:00
2011-09-19 08:54:48 +00:00
switch ( $vars [ 'view' ])
2011-05-01 20:29:31 +00:00
{
case 'prefixes_ipv4unicast' :
case 'prefixes_ipv4multicast' :
case 'prefixes_ipv4vpn' :
case 'prefixes_ipv6unicast' :
case 'prefixes_ipv6multicast' :
2011-09-19 08:54:48 +00:00
list (, $afisafi ) = explode ( " _ " , $vars [ 'view' ]);
2011-05-01 20:29:31 +00:00
if ( isset ( $peer [ 'afisafi' ][ $afisafi ])) { $peer [ 'graph' ] = 1 ; }
2012-05-25 12:24:34 +00:00
// FIXME no break??
2011-05-01 20:29:31 +00:00
case 'updates' :
2011-09-19 08:54:48 +00:00
$graph_array [ 'type' ] = " bgp_ " . $vars [ 'view' ];
2011-05-01 20:29:31 +00:00
$graph_array [ 'id' ] = $peer [ 'bgpPeer_id' ];
}
2011-04-19 21:54:43 +00:00
2011-09-19 08:54:48 +00:00
switch ( $vars [ 'view' ])
2011-05-01 20:29:31 +00:00
{
case 'macaccounting_bits' :
case 'macaccounting_pkts' :
2012-05-16 13:25:50 +00:00
$acc = dbFetchRow ( " SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = ? AND M.mac = I.mac_address AND P.port_id = M.port_id AND D.device_id = P.device_id " , array ( $peer [ 'bgpPeerIdentifier' ]));
2011-05-01 20:29:31 +00:00
$database = $config [ 'rrd_dir' ] . " / " . $device [ 'hostname' ] . " /cip- " . $acc [ 'ifIndex' ] . " - " . $acc [ 'mac' ] . " .rrd " ;
if ( is_array ( $acc ) && is_file ( $database ))
{
$peer [ 'graph' ] = 1 ;
$graph_array [ 'id' ] = $acc [ 'ma_id' ];
2011-09-19 08:54:48 +00:00
$graph_array [ 'type' ] = $vars [ 'view' ];
2011-05-01 20:29:31 +00:00
}
}
2011-04-19 21:54:43 +00:00
2011-09-19 08:54:48 +00:00
if ( $vars [ 'view' ] == 'updates' ) { $peer [ 'graph' ] = 1 ; }
2011-04-19 21:54:43 +00:00
2011-09-20 14:37:54 +00:00
if ( $peer [ 'graph' ])
2011-05-01 20:29:31 +00:00
{
$graph_array [ 'height' ] = " 100 " ;
$graph_array [ 'width' ] = " 216 " ;
2012-05-06 18:38:11 +00:00
$graph_array [ 'to' ] = $config [ 'time' ][ 'now' ];
2011-05-01 20:29:31 +00:00
echo ( '<tr bgcolor="' . $bg_colour . '"' . ( $bg_image ? ' background="' . $bg_image . '"' : '' ) . '"><td colspan="7">' );
2012-04-06 13:56:23 +00:00
2012-04-26 16:49:38 +00:00
include ( " includes/print-graphrow.inc.php " );
2012-04-06 13:56:23 +00:00
2011-05-01 20:29:31 +00:00
echo ( " </td></tr> " );
}
2010-11-25 15:32:47 +00:00
2011-05-01 20:29:31 +00:00
$i ++ ;
2011-04-29 17:11:07 +00:00
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 >