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_ipv4unicast") { echo(""); } echo("IPv4"); if ($_GET['optb'] == "prefixes_ipv4unicast") { echo(""); } echo(" | "); if ($_GET['optb'] == "prefixes_vpnv4unicast") { echo(""); } echo("VPNv4"); if ($_GET['optb'] == "prefixes_vpnv4unicast") { echo(""); } echo(" | "); if ($_GET['optb'] == "prefixes_ipv6unicast") { echo(""); } echo("IPv6"); if ($_GET['optb'] == "prefixes_ipv6unicast") { echo(""); } echo(" | Traffic: "); if ($_GET['optb'] == "macaccounting_bits") { echo(""); } echo("Bits"); if ($_GET['optb'] == "macaccounting_bits") { echo(""); } echo(" | "); if ($_GET['optb'] == "macaccounting_pkts") { echo(""); } echo("Packets"); if ($_GET['optb'] == "macaccounting_pkts") { echo(""); } print_optionbar_end(); echo(''); echo(''); $i = "1"; foreach (dbFetchRows("SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `bgpPEerRemoteAs`, `bgpPeerIdentifier`", array($device['device_id'])) as $peer) { $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'])); 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 = ? AND I.interface_id = A.interface_id)"; $query .= " AND D.device_id = I.device_id"; $ipv4_host = dbFetchRow($query,array($peer['bgpPeerIdentifier'])); $query = "SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE "; $query .= "(A.ipv6_address = ? AND I.interface_id = A.interface_id)"; $query .= " AND D.device_id = I.device_id"; $ipv6_host = dbFetchRow($query,array($peer['bgpPeerIdentifier'])); 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.""; } } unset($peer_af); unset($sep); foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($device['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) { $afi = $afisafi['afi']; $safi = $afisafi['safi']; $this_afisafi = $afi.$safi; $peer['afi'] .= $sep . $afi .".".$safi; $sep = "
"; $peer['afisafi'][$this_afisafi] = 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(" "); unset($invalid); switch ($_GET['optb']) { case 'prefixes_ipv4unicast': case 'prefixes_ipv4multicast': case 'prefixes_ipv4vpn': case 'prefixes_ipv6unicast': case 'prefixes_ipv6multicast': list(,$afisafi) = explode("_", $_GET['optb']); if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; } # FIXME no break?? case 'updates': $graph_array['type'] = "bgp_" . $_GET['optb']; $graph_array['id'] = $peer['bgpPeer_id']; } switch ($_GET['optb']) { case 'macaccounting_bits': case 'macaccounting_pkts': $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.interface_id = M.interface_id AND D.device_id = P.device_id", array($peer['bgpPeerIdentifier'])); $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']; $graph_array['type'] = $_GET['optb']; } } if ($_GET['optb'] == 'updates') { $peer['graph'] = 1; } if($peer['graph']) { $graph_array['height'] = "100"; $graph_array['width'] = "216"; $graph_array['to'] = $now; echo('"); } $i++; unset($valid_afi_safi); } ?>
Peer addressTypeRemote ASStateUptime
".$i." " . $peeraddresslink . "
".generate_device_link($peer, shorthost($peer['hostname']), 'bgp/')."
$peer_type " . (isset($peer['afi']) ? $peer['afi'] : '') . " AS" . $peer['bgpPeerRemoteAs'] . "
" . $peer['astext'] . "
" . $peer['bgpPeerAdminStatus'] . "
" . $peer['bgpPeerState'] . "
" .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
Updates " . $peer['bgpPeerInUpdates'] . " " . $peer['bgpPeerOutUpdates'] . "
'); include("includes/print-quadgraphs.inc.php"); echo("