From 11bb5953ff9ea2861fb615a041ca80c8ce35cbfc Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Fri, 29 Apr 2011 17:11:07 +0000 Subject: [PATCH] fixes :> git-svn-id: http://www.observium.org/svn/observer/trunk@2202 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/pages/device/routing/bgp.inc.php | 121 +++++++++++++------------- 1 file changed, 59 insertions(+), 62 deletions(-) diff --git a/html/pages/device/routing/bgp.inc.php b/html/pages/device/routing/bgp.inc.php index e9a423a030..2fba62b194 100644 --- a/html/pages/device/routing/bgp.inc.php +++ b/html/pages/device/routing/bgp.inc.php @@ -19,27 +19,32 @@ print_optionbar_start(); echo(" | Prefixes: "); - if ($_GET['optb'] == "prefixes" && $_GET['optc'] == "ipv4.unicast") { echo(""); } - echo("IPv4"); - if ($_GET['optb'] == "prefixes" && $_GET['optc'] == "ipv4.unicast") { echo(""); } + if ($_GET['optb'] == "prefixes_ipv4unicast") { echo(""); } + echo("IPv4"); + if ($_GET['optb'] == "prefixes_ipv4unicast") { echo(""); } echo(" | "); - if ($_GET['optb'] == "prefixes" && $_GET['optc'] == "vpnv4.unicast") { echo(""); } - echo("VPNv4"); - if ($_GET['optb'] == "prefixes" && $_GET['optc'] == "vpnv4.unicast") { echo(""); } + if ($_GET['optb'] == "prefixes_vpnv4unicast") { echo(""); } + echo("VPNv4"); + if ($_GET['optb'] == "prefixes_vpnv4unicast") { echo(""); } echo(" | "); - if ($_GET['optb'] == "prefixes" && $_GET['optc'] == "ipv6.unicast") { echo(""); } - echo("IPv6"); - if ($_GET['optb'] == "prefixes" && $_GET['optc'] == "ipv6.unicast") { echo(""); } + if ($_GET['optb'] == "prefixes_ipv6unicast") { echo(""); } + echo("IPv6"); + if ($_GET['optb'] == "prefixes_ipv6unicast") { echo(""); } echo(" | Traffic: "); - if ($_GET['optb'] == "macaccounting") { echo(""); } - echo("Mac Accounting"); - if ($_GET['optb'] == "macaccounting") { echo(""); } + 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(); @@ -110,9 +115,13 @@ while ($peer = mysql_fetch_assoc($peer_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! + $this_afisafi = $afi.$safi; + #$peer['afi'] .= $sep . $config['afi'][$afi][$safi]; ##### CLEAN ME UP, I AM MESSY AND I SMELL OF CHEESE! FIXME! + $peer['afi'] .= $sep . $afi .".".$safi; $sep = "
"; - $valid_afi_safi[$afi][$safi] = 1; ## Build a list of valid AFI/SAFI for this peer + $peer['afisafi'][$this_afisafi] = 1; ## Build a list of valid AFI/SAFI for this peer + + } unset($sep); @@ -129,7 +138,7 @@ while ($peer = mysql_fetch_assoc($peer_query)) echo(" ".$i." " . $peeraddresslink . "
".generate_device_link($peer, shorthost($peer['hostname']), 'bgp/')." $peer_type - " . (isset($peer_af) ? $peer_af : '') . " + " . (isset($peer['afi']) ? $peer['afi'] : '') . " AS" . $peer['bgpPeerRemoteAs'] . "
" . $peer['astext'] . " " . $peer['bgpPeerAdminStatus'] . "
" . $peer['bgpPeerState'] . "
" .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
@@ -137,62 +146,50 @@ while ($peer = mysql_fetch_assoc($peer_query)) " . $peer['bgpPeerOutUpdates'] . " "); - if ($_GET['optb'] != "basic" && isset($_GET['optb']) && $_GET['optb'] != "macaccounting") - { - unset($graph_array); - foreach (explode(" ", $_GET['optb']) as $graph_type) + 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; } + case 'updates': + $graph_array['type'] = "bgp_" . $_GET['optb']; + $graph_array['id'] = $peer['bgpPeer_id']; + } - 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"; - } + switch ($_GET['optb']) + { + case 'macaccounting_bits': + case 'macaccounting_pkts': + $acc = mysql_fetch_assoc(mysql_query("SELECT * FROM `ipv4_mac` AS I, `mac_accounting` AS M, `ports` AS P, `devices` AS D WHERE I.ipv4_address = '".$peer['bgpPeerIdentifier']."' AND M.mac = I.mac_address AND P.interface_id = M.interface_id AND D.device_id = P.device_id")); + $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']; + } + } - $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['optb'] == 'updates') { $peer['graph'] = 1; } + + if($peer['graph']) + { + $graph_array['height'] = "100"; + $graph_array['width'] = "216"; + $graph_array['to'] = $now; + echo(''); include("includes/print-quadgraphs.inc.php"); echo(""); - } - } - } + $i++; - 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(''); - include("includes/print-quadgraphs.inc.php"); - echo(""); - - } - } - - $i++; unset($valid_afi_safi); } ?>