Local AS :
BGP » "); if (!isset($_GET['optb'])) { echo(""); } echo("Basic"); if (!isset($_GET['optb'])) { echo(""); } echo(" | "); if ($_GET['optb'] == "updates") { echo(""); } echo("Updates"); if ($_GET['optb'] == "updates") { echo(""); } echo(" | Prefixes: "); if ($_GET['optb'] == "prefixes" && $_GET['optc'] == "ipv4.unicast") { echo(""); } echo("IPv4"); if ($_GET['optb'] == "prefixes" && $_GET['optc'] == "ipv4.unicast") { echo(""); } echo(" | "); if ($_GET['optb'] == "prefixes" && $_GET['optc'] == "vpnv4.unicast") { echo(""); } echo("VPNv4"); if ($_GET['optb'] == "prefixes" && $_GET['optc'] == "vpnv4.unicast") { echo(""); } echo(" | "); if ($_GET['optb'] == "prefixes" && $_GET['optc'] == "ipv6.unicast") { echo(""); } echo("IPv6"); if ($_GET['optb'] == "prefixes" && $_GET['optc'] == "ipv6.unicast") { echo(""); } echo(" | Traffic: "); if ($_GET['optb'] == "macaccounting") { echo(""); } echo("Mac Accounting"); if ($_GET['optb'] == "macaccounting") { echo(""); } print_optionbar_end(); echo(''); echo(''); $i = "1"; $peer_query = mysql_query("select * from bgpPeers WHERE device_id = '".$device['device_id']."' ORDER BY bgpPeerRemoteAs, bgpPeerIdentifier"); 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; } 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; } if ($peer['bgpPeerRemoteAs'] == $device['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP"; } $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 { #$peername = gethostbyaddr($peer['bgpPeerIdentifier']); ## FFffuuu DNS if ($peername == $peer['bgpPeerIdentifier']) { unset($peername); } else { $peername = "".$peername.""; } } $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 = "
"; $valid_afi_safi[$afi][$safi] = 1; ## Build a list of valid AFI/SAFI for this peer } unset($sep); $graph_type = "bgp_updates"; $peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=$day&to=$now&width=500&height=150"; $peeraddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer['bgpPeerIdentifier'] . ""; echo('
"); echo(" "); if ($_GET['optb'] != "basic" && isset($_GET['optb']) && $_GET['optb'] != "macaccounting") { unset($graph_array); foreach (explode(" ", $_GET['optb']) as $graph_type) { 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]) { echo('"); } } } if ($_GET['opta'] == "macaccounting" && $has_macaccounting) { $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"; if (is_file($database)) { $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('"); } } $i++; unset($valid_afi_safi); } ?>
Peer addressTypeRemote ASStateUptime
".$i." " . $peeraddresslink . "
".generate_device_link($peer, shorthost($peer['hostname']), 'bgp/')."
$peer_type " . (isset($peer_af) ? $peer_af : '') . " AS" . $peer['bgpPeerRemoteAs'] . "
" . $peer['astext'] . "
" . $peer['bgpPeerAdminStatus'] . "
" . $peer['bgpPeerState'] . "
" .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
Updates " . $peer['bgpPeerInUpdates'] . " " . $peer['bgpPeerOutUpdates'] . "
'); include("includes/print-quadgraphs.inc.php"); echo("
'); include("includes/print-quadgraphs.inc.php"); echo("