2008-03-15 17:58:15 +00:00
<? php
2009-01-07 12:37:18 +00:00
echo ( "
2009-09-24 14:38:17 +00:00
<div style='padding: 10px; height: 20px; clear: both; display: block;'>
2009-03-11 15:30:01 +00:00
<div style='float: left; font-size: 22px; font-weight: bold;'>Local AS : " . $device [ 'bgpLocalAs' ] . "</div>
2009-09-24 14:38:17 +00:00
</div>" );
2010-01-09 17:37:51 +00:00
print_optionbar_start ();
2009-09-24 14:38:17 +00:00
echo ( "
2010-01-09 17:37:51 +00:00
<div style='margin: auto; text-align: left; padding-left: 11px; clear: both; display:block; height:20px;'>
2009-09-24 14:38:17 +00:00
<a href='" . $config [ 'base_url' ] . "/device/" . $_GET [ 'id' ] . "/bgp/'>No Graphs</a> |
2010-08-01 14:37:36 +00:00
<a href='" . $config [ 'base_url' ] . "/device/" . $_GET [ 'id' ] . "/bgp/updates/'>Updates</a> | Prefixes:
2010-11-24 14:25:03 +00:00
<a href='" . $config [ 'base_url' ] . "/device/" . $_GET [ 'id' ] . "/bgp/prefixes/ipv4.unicast/'>IPv4</a> |
<a href='" . $config [ 'base_url' ] . "/device/" . $_GET [ 'id' ] . "/bgp/prefixes/ipv4.vpn/'>VPNv4</a> |
<a href='" . $config [ 'base_url' ] . "/device/" . $_GET [ 'id' ] . "/bgp/prefixes/ipv6.unicast/'>IPv6</a>
2009-05-11 13:43:59 +00:00
| Traffic:
<a href='" . $config [ 'base_url' ] . "/device/" . $_GET [ 'id' ] . "/bgp/macaccounting/'>Mac Accounting</a>
2009-09-24 14:38:17 +00:00
</div>
" );
2010-01-09 17:37:51 +00:00
print_optionbar_end ();
2009-01-07 12:37:18 +00:00
2009-03-30 00:35:38 +00:00
echo ( "<div style='margin: 5px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>" );
2008-03-18 13:35:17 +00:00
2008-03-15 17:58:15 +00:00
$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 )) {
2010-02-08 18:07:00 +00:00
unset ( $bg_image );
2008-03-15 17:58:15 +00:00
if ( ! is_integer ( $i / 2 )) { $bg_colour = $list_colour_a ; } else { $bg_colour = $list_colour_b ; }
2008-03-18 13:35:17 +00:00
#if($peer['bgpPeerAdminStatus'] == "start") { $img = "images/16/accept.png"; } else { $img = "images/16/delete.png"; }
2010-02-08 16:48:15 +00:00
if ( $peer [ 'bgpPeerState' ] == "established" ) { $col = "green" ; } else { $col = "red" ; $bg_image = "images/warning-background.png" ; }
if ( $peer [ 'bgpPeerAdminStatus' ] == "start" || $peer [ 'bgpPeerAdminStatus' ] == "running" ) { $admin_col = "green" ; } else { $admin_col = "red" ; $bg_image = "images/warning-background.png" ; }
2008-03-18 13:35:17 +00:00
if ( $peer [ 'bgpPeerRemoteAs' ] == $device [ 'bgpLocalAs' ]) { $peer_type = "<span style='color: #00f;'>iBGP</span>" ; } else { $peer_type = "<span style='color: #0a0;'>eBGP</span>" ; }
2008-03-15 17:58:15 +00:00
2010-02-20 17:22:22 +00:00
$query = "SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE " ;
2010-01-09 23:21:02 +00:00
$query .= "(A.ipv4_address = '" . $peer [ 'bgpPeerIdentifier' ] . "' AND I.interface_id = A.interface_id)" ;
$query .= " AND D.device_id = I.device_id" ;
2010-01-27 21:51:59 +00:00
$ipv4_host = mysql_fetch_array ( mysql_query ( $query ));
2008-03-15 17:58:15 +00:00
2010-02-20 17:22:22 +00:00
$query = "SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE " ;
2010-01-27 21:51:59 +00:00
$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_array ( mysql_query ( $query ));
2010-01-27 21:54:33 +00:00
if ( $ipv4_host ) {
$peerhost = $ipv4_host ;
} elseif ( $ipv6_host ) {
$peerhost = $ipv6_host ;
} else { unset ( $peerhost ); }
2010-01-27 21:51:59 +00:00
if ( $peerhost ) {
2010-08-02 22:09:52 +00:00
$peername = generate_device_link ( $peerhost );
2010-01-27 21:51:59 +00:00
} else {
$peername = gethostbyaddr ( $peer [ 'bgpPeerIdentifier' ]);
if ( $peername == $peer [ 'bgpPeerIdentifier' ]) {
unset ( $peername );
} else {
$peername = "<i>" . $peername . "<i>" ;
}
}
2008-03-15 17:58:15 +00:00
2009-03-30 00:35:38 +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_array ( $af_query )) {
2009-03-30 11:20:18 +00:00
$afi = $afisafi [ 'afi' ];
2009-03-30 00:35:38 +00:00
$safi = $afisafi [ 'safi' ];
2009-03-30 11:20:18 +00:00
$peer_af .= $sep . $config [ 'afi' ][ $afi ][ $safi ]; ##### CLEAN ME UP, I AM MESSY AND I SMELL OF CHEESE!
2009-03-30 00:35:38 +00:00
$sep = "<br />" ;
2009-03-30 11:20:18 +00:00
$valid_afi_safi [ $afi ][ $safi ] = 1 ; ## Build a list of valid AFI/SAFI for this peer
2009-03-30 00:35:38 +00:00
}
2010-01-27 21:51:59 +00:00
2009-03-30 00:35:38 +00:00
unset ( $sep );
2010-02-08 16:48:15 +00:00
echo ( "<tr bgcolor= $bg_colour background= $bg_image >
2008-03-29 17:36:54 +00:00
<td width=20><span class=list-large> $i </span></td>
2008-03-18 13:35:17 +00:00
<td><span class=list-large>" . $peer [ 'bgpPeerIdentifier' ] . "</span><br />" . $peername . "</td>
<td> $peer_type </td>
2010-01-09 23:21:02 +00:00
<td style='font-size: 10px; font-weight: bold; line-height: 10px;'>" . ( isset ( $peer_af ) ? $peer_af : '' ) . "</td>
2008-03-18 13:35:17 +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' ] . "
<img src='images/16/arrow_up.png' align=absmiddle> " . $peer [ 'bgpPeerOutUpdates' ] . "</td></tr>" );
2008-11-05 20:49:29 +00:00
2010-01-09 23:21:02 +00:00
if ( isset ( $_GET [ 'opta' ]) && $_GET [ 'opta' ] != "macaccounting" ) {
2010-02-08 16:21:40 +00:00
foreach ( explode ( " " , $_GET [ 'opta' ]) as $graph_type ) {
2010-11-24 14:25:03 +00:00
if ( $graph_type == "prefixes" ) { list ( $afi , $safi ) = explode ( "." , $_GET [ 'optb' ]); $afisafi = "&afi= $afi &safi= $safi " ; }
2010-08-01 14:37:36 +00:00
if ( $graph_type == "updates" || $valid_afi_safi [ $afi ][ $safi ]) {
$daily_traffic = $config [ 'base_url' ] . "/graph.php?id=" . $peer [ 'bgpPeer_id' ] . "&type=bgp_ $graph_type &from= $day &to= $now &width=210&height=100 $afisafi " ;
$daily_url = $config [ 'base_url' ] . "/graph.php?id=" . $peer [ 'bgpPeer_id' ] . "&type=bgp_ $graph_type &from= $day &to= $now &width=500&height=150 $afisafi " ;
$weekly_traffic = $config [ 'base_url' ] . "/graph.php?id=" . $peer [ 'bgpPeer_id' ] . "&type=bgp_ $graph_type &from= $week &to= $now &width=210&height=100 $afisafi " ;
$weekly_url = $config [ 'base_url' ] . "/graph.php?id=" . $peer [ 'bgpPeer_id' ] . "&type=bgp_ $graph_type &from= $week &to= $now &width=500&height=150 $afisafi " ;
$monthly_traffic = $config [ 'base_url' ] . "/graph.php?id=" . $peer [ 'bgpPeer_id' ] . "&type=bgp_ $graph_type &from= $month &to= $now &width=210&height=100 $afisafi " ;
$monthly_url = $config [ 'base_url' ] . "/graph.php?id=" . $peer [ 'bgpPeer_id' ] . "&type=bgp_ $graph_type &from= $month &to= $now &width=500&height=150 $afisafi " ;
$yearly_traffic = $config [ 'base_url' ] . "/graph.php?id=" . $peer [ 'bgpPeer_id' ] . "&type=bgp_ $graph_type &from= $year &to= $now &width=210&height=100 $afisafi " ;
$yearly_url = $config [ 'base_url' ] . "/graph.php?id=" . $peer [ 'bgpPeer_id' ] . "&type=bgp_ $graph_type &from= $year &to= $now &width=500&height=150 $afisafi " ;
2010-02-08 16:21:40 +00:00
echo ( "<tr bgcolor= $bg_colour ><td colspan=7>" );
echo ( "<a href='' onmouseover= \" return overlib('<img src=\' $daily_url \'>', LEFT" . $config [ 'overlib_defaults' ] . "); \" onmouseout= \" return nd(); \" ><img src=' $daily_traffic ' border=0></a> " );
echo ( "<a href='' onmouseover= \" return overlib('<img src=\' $weekly_url \'>', LEFT" . $config [ 'overlib_defaults' ] . "); \" onmouseout= \" return nd(); \" ><img src=' $weekly_traffic ' border=0></a> " );
echo ( "<a href='' 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='' 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>" );
}
}
}
if ( $_GET [ 'opta' ] == "macaccounting" ) {
if ( 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 )) {
2010-02-20 17:22:22 +00:00
$acc = mysql_fetch_array ( 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" ));
2010-02-08 18:07:00 +00:00
$graph_type = "mac_acc_bits" ;
$database = $config [ 'rrd_dir' ] . "/" . $device [ 'hostname' ] . "/cip-" . $acc [ 'ifIndex' ] . "-" . $acc [ 'mac' ] . ".rrd" ;
2010-02-08 16:21:40 +00:00
if ( is_file ( $database ) ) {
$daily_traffic = "graph.php?id=" . $acc [ 'ma_id' ] . "&type= $graph_type &from= $day &to= $now &width=210&height=100" ;
$daily_url = "graph.php?id=" . $acc [ 'ma_id' ] . "&type= $graph_type &from= $day &to= $now &width=500&height=150" ;
$weekly_traffic = "graph.php?id=" . $acc [ 'ma_id' ] . "&type= $graph_type &from= $week &to= $now &width=210&height=100" ;
$weekly_url = "graph.php?id=" . $acc [ 'ma_id' ] . "&type= $graph_type &from= $week &to= $now &width=500&height=150" ;
$monthly_traffic = "graph.php?id=" . $acc [ 'ma_id' ] . "&type= $graph_type &from= $month &to= $now &width=210&height=100" ;
$monthly_url = "graph.php?id=" . $acc [ 'ma_id' ] . "&type= $graph_type &from= $month &to= $now &width=500&height=150" ;
$yearly_traffic = "graph.php?id=" . $acc [ 'ma_id' ] . "&type= $graph_type &from= $year &to= $now &width=210&height=100" ;
$yearly_url = "graph.php?id=" . $acc [ 'ma_id' ] . "&type= $graph_type &from= $year &to= $now &width=500&height=150" ;
echo ( "<tr bgcolor= $bg_colour ><td colspan=7>" );
echo ( "<a href='?page=interface&id=" . $interface [ 'ma_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=" . $interface [ 'ma_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=" . $interface [ 'ma_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=" . $interface [ 'ma_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 ++ ;
2009-06-10 05:42:48 +00:00
}
2010-02-08 16:21:40 +00:00
echo ( "</table></div>" );
2008-03-15 17:58:15 +00:00
?>