BGP » ');
if(!$_GET['optb']) { $_GET['optb'] = "all"; }
if ($_GET['opta'] == "bgp" && $_GET['optb'] == "all") { echo(""); }
echo(' | ');
if ($_GET['opta'] == "bgp" && $_GET['optb'] == "internal") { echo(""); }
echo(" | ");
if ($_GET['opta'] == "bgp" && $_GET['optb'] == "external") { echo(""); }
echo(" | ");
if ($_GET['opta'] == "bgp" && $_GET['optb'] == "disabled") { echo(""); }
echo(" | ");
if ($_GET['opta'] == "bgp" && $_GET['optb'] == "alerts") { echo(""); }
echo('');
## End BGP Menu
echo('
');
if(!$_GET['optc']) { $_GET['optc'] = "nographs"; }
if ($_GET['opta'] == "bgp" && $_GET['optc'] == "nographs") { echo(""); }
echo(" | ");
if ($_GET['opta'] == "bgp" && $_GET['optc'] == "updates") { echo(""); }
echo(" | Prefixes: Unicast (");
if ($_GET['opta'] == "bgp" && $_GET['optc'] == "prefixes_ipv4unicast") { echo(""); }
echo("|");
if ($_GET['opta'] == "bgp" && $_GET['optc'] == "prefixes_ipv6unicast") { echo(""); }
echo("|");
if ($_GET['opta'] == "bgp" && $_GET['optc'] == "prefixes_ipv4vpn") { echo(""); }
echo(")");
echo(" | Multicast (");
if ($_GET['opta'] == "bgp" && $_GET['optc'] == "prefixes_ipv4multicast") { echo(""); }
echo("|");
if ($_GET['opta'] == "bgp" && $_GET['optc'] == "prefixes_ipv6multicast") { echo(""); }
echo(")");
echo(" | MAC (");
if ($_GET['opta'] == "bgp" && $_GET['optc'] == "macaccounting_bits") { echo(""); }
echo("|");
if ($_GET['opta'] == "bgp" && $_GET['optc'] == "macaccounting_pkts") { echo(""); }
echo(")");
echo('
');
print_optionbar_end();
echo("");
echo(' | Local address | | Peer address | Type | Family | Remote AS | State | Uptime / Updates |
');
$i = "1";
if ($_GET['optb'] == "alerts")
{
$where = "AND (B.bgpPeerAdminStatus = 'start' or B.bgpPeerAdminStatus = 'running') AND B.bgpPeerState != 'established'";
} elseif ($_GET['optb'] == "disabled") {
$where = "AND B.bgpPeerAdminStatus = 'stop'";
} elseif ($_GET['optb'] == "external") {
$where = "AND D.bgpLocalAs != B.bgpPeerRemoteAs";
} elseif ($_GET['optb'] == "internal") {
$where = "AND D.bgpLocalAs = B.bgpPeerRemoteAs";
}
$peer_query = "select * from bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id ".$where." ORDER BY D.hostname, B.bgpPeerRemoteAs, B.bgpPeerIdentifier";
foreach(dbFetchRows($peer_query) as $peer)
{
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'] == $peer['bgpLocalAs']) { $peer_type = "iBGP"; } else { $peer_type = "eBGP";
if ($peer['bgpPeerRemoteAS'] >= '64512' && $peer['bgpPeerRemoteAS'] <= '65535') { $peer_type = "Priv eBGP"; }
}
$peerhost = dbFetchRow("SELECT * FROM ipaddr AS A, ports AS I, devices AS D WHERE A.addr = ? AND I.interface_id = A.interface_id AND D.device_id = I.device_id", array($peer['bgpPeerIdentifier']));
if ($peerhost) { $peername = generate_device_link($peerhost, shorthost($peerhost['hostname'])); } else { unset($peername); }
// display overlib graphs
$graph_type = "bgp_updates";
$local_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=$day&to=$now&width=500&height=150&&afi=ipv4&safi=unicast";
$localaddresslink = "', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer['bgpLocalAddr'] . "";
$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('");
unset($sep);
foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?", array($peer['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);
echo(" |
" . $localaddresslink . " ".generate_device_link($peer, shorthost($peer['hostname']), 'routing/bgp/')." |
» |
" . $peeraddresslink . " |
$peer_type |
".$peer['afi']." |
AS" . $peer['bgpPeerRemoteAs'] . " " . $peer['astext'] . " |
" . $peer['bgpPeerAdminStatus'] . " " . $peer['bgpPeerState'] . " |
" .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
Updates " . format_si($peer['bgpPeerInUpdates']) . "
" . format_si($peer['bgpPeerOutUpdates']) . " |
");
unset($invalid);
switch ($_GET['optc'])
{
case 'prefixes_ipv4unicast':
case 'prefixes_ipv4multicast':
case 'prefixes_ipv4vpn':
case 'prefixes_ipv6unicast':
case 'prefixes_ipv6multicast':
list(,$afisafi) = explode("_", $_GET['optc']);
if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; }
case 'updates':
$graph_array['type'] = "bgp_" . $_GET['optc'];
$graph_array['id'] = $peer['bgpPeer_id'];
}
switch ($_GET['optc'])
{
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['optc'];
}
}
if ($_GET['optc'] == 'updates') { $peer['graph'] = 1; }
if($peer['graph'])
{
$graph_array['height'] = "100";
$graph_array['width'] = "220";
$graph_array['to'] = $now;
echo('');
include("includes/print-quadgraphs.inc.php");
echo(" |
");
}
$i++;
}
echo("
");
}
?>