From 28558969c4aeb18746bcea42397b4d337a2e69bf Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Fri, 29 Apr 2011 16:32:55 +0000 Subject: [PATCH] improvements to BGP stuff git-svn-id: http://www.observium.org/svn/observer/trunk@2200 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/includes/graphs/bgp/prefixes.inc.php | 2 - .../bits.inc.php} | 0 .../pkts.inc.php} | 0 html/pages/device/routing/bgp.inc.php | 2 +- html/pages/routing.inc.php | 54 ++++--- html/pages/routing/bgp.inc.php | 139 ++++++++++++------ html/pages/routing/cef.inc.php | 0 html/pages/routing/ospf.inc.php | 0 html/pages/routing/overview.inc.php | 26 ++++ html/pages/routing/overview/bgp.inc.php | 13 ++ includes/static-config.php | 1 + 11 files changed, 172 insertions(+), 65 deletions(-) rename html/includes/graphs/{port/mac_acc_bits.inc.php => macaccounting/bits.inc.php} (100%) rename html/includes/graphs/{port/mac_acc_pkts.inc.php => macaccounting/pkts.inc.php} (100%) create mode 100644 html/pages/routing/cef.inc.php create mode 100644 html/pages/routing/ospf.inc.php create mode 100644 html/pages/routing/overview.inc.php diff --git a/html/includes/graphs/bgp/prefixes.inc.php b/html/includes/graphs/bgp/prefixes.inc.php index 350342502..c6d568da3 100644 --- a/html/includes/graphs/bgp/prefixes.inc.php +++ b/html/includes/graphs/bgp/prefixes.inc.php @@ -4,8 +4,6 @@ include("includes/graphs/common.inc.php"); $scale_min = "0"; -$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/". safename("cbgp-" . $data['bgpPeerIdentifier'] . ".".$_GET['afi'].".".$_GET['safi'].".rrd"); - $rra = "AcceptedPrefixes"; $colour_area = "AA66AA"; diff --git a/html/includes/graphs/port/mac_acc_bits.inc.php b/html/includes/graphs/macaccounting/bits.inc.php similarity index 100% rename from html/includes/graphs/port/mac_acc_bits.inc.php rename to html/includes/graphs/macaccounting/bits.inc.php diff --git a/html/includes/graphs/port/mac_acc_pkts.inc.php b/html/includes/graphs/macaccounting/pkts.inc.php similarity index 100% rename from html/includes/graphs/port/mac_acc_pkts.inc.php rename to html/includes/graphs/macaccounting/pkts.inc.php diff --git a/html/pages/device/routing/bgp.inc.php b/html/pages/device/routing/bgp.inc.php index b629069b7..e9a423a03 100644 --- a/html/pages/device/routing/bgp.inc.php +++ b/html/pages/device/routing/bgp.inc.php @@ -105,7 +105,7 @@ while ($peer = mysql_fetch_assoc($peer_query)) $af_query = mysql_query("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '".$peer['bgpPeerIdentifier']."'"); unset($peer_af); - + unset($sep); while ($afisafi = mysql_fetch_assoc($af_query)) { $afi = $afisafi['afi']; diff --git a/html/pages/routing.inc.php b/html/pages/routing.inc.php index 620a921d7..fec16c52d 100644 --- a/html/pages/routing.inc.php +++ b/html/pages/routing.inc.php @@ -3,44 +3,56 @@ if (!$_GET['opta']) { $_GET['opta'] = "overview"; } if ($_GET['optb'] == "graphs" || $_GET['optc'] == "graphs") { $graphs = "graphs"; } else { $graphs = "nographs"; } -print_optionbar_start('', ''); +$datas[] = 'overview'; - echo('Routing » '); +$vrf_count = @mysql_result(mysql_query("SELECT COUNT(*) FROM `vrfs`"), 0); +if($vrf_count) { $datas[] = 'vrf'; } - if ($_GET['opta'] == "overview") { echo(""); } - echo('Overview'); - if ($_GET['opta'] == "overview") { echo(""); } +$bgp_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `bgpPeers`"), 0); +if ($bgp_count) { $datas[] = 'bgp'; } - echo(" | "); +$cef_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `cef_switching`"), 0); +if ($cef_count) { $datas[] = 'cef'; } - ## Start BGP Menu -- FIXME only show if BGP enabled? - if ($_GET['opta'] == "bgp") { echo(""); } - echo('BGP'); - if ($_GET['opta'] == "bgp") { echo(""); } +$ospf_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `ospf_instances`"), 0); +if ($ospf_count) { $datas[] = 'ospf'; } - echo(" | "); +$type_text['overview'] = "Overview"; +$type_text['bgp'] = "BGP"; +$type_text['cef'] = "CEF"; +$type_text['ospf'] = "OSPF"; +$type_text['vrf'] = "VRFs"; - ## Start OSPF Menu -- FIXME only show if BGP enabled? - if ($_GET['opta'] == "ospf") { echo(""); } - echo('OSPF'); - if ($_GET['opta'] == "ospf") { echo(""); } +print_optionbar_start(); - echo(" | "); +if (!$_GET['opta']) { $_GET['opta'] = "overview"; } - ## Start VRF Menu -- FIXME only show if BGP enabled? - if ($_GET['opta'] == "vrf") { echo(""); } - echo('VRF'); - if ($_GET['opta'] == "vrf") { echo(""); } +echo("Routing » "); +unset($sep); +foreach ($datas as $type) +{ + echo($sep); + if ($_GET['opta'] == $type) + { + echo(''); + } -print_optionbar_end('', ''); + echo(" " . $type_text[$type] .""); + if ($_GET['opta'] == $type) { echo(""); } + $sep = " | "; +} + +print_optionbar_end(); switch ($_GET['opta']) { case 'overview': case 'bgp': case 'vrf': + case 'cef': + case 'ospf': include('pages/routing/'.$_GET['opta'].'.inc.php'); break; default: diff --git a/html/pages/routing/bgp.inc.php b/html/pages/routing/bgp.inc.php index 71a1b6058..ac23cfb82 100644 --- a/html/pages/routing/bgp.inc.php +++ b/html/pages/routing/bgp.inc.php @@ -11,6 +11,8 @@ else echo('BGP » '); + if(!$_GET['optb']) { $_GET['optb'] = "all"; } + if ($_GET['opta'] == "bgp" && $_GET['optb'] == "all") { echo(""); } echo('All'); if ($_GET['opta'] == "bgp" && $_GET['optb'] == "all") { echo(""); } @@ -34,42 +36,52 @@ else echo(''); ## End BGP Menu - if(!isset($graphs)) { $graphs == "nographs"; } - echo('
'); - if ($graphs == "graphs") { echo(''); } + if(!$_GET['optc']) { $_GET['optc'] = "nographs"; } - if(!isset($_GET['optc'])) - { - echo(' Graphs'); - } else { - echo(' Graphs'); - } + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "nographs") { echo(""); } + echo('No Graphs'); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "nographs") { echo(""); } + echo(" | "); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "updates") { echo(""); } + echo('Updates'); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "updates") { echo(""); } - if ($graphs == "graphs") - { - echo(''); - } + echo(" | Prefixes: Unicast ("); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "prefixes_ipv4unicast") { echo(""); } + echo('IPv4'); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "prefixes_ipv4unicast") { echo(""); } + echo("|"); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "prefixes_ipv6unicast") { echo(""); } + echo('IPv6'); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "prefixes_ipv6unicast") { echo(""); } + echo("|"); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "prefixes_ipv4vpn") { echo(""); } + echo('VPNv4'); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "prefixes_ipv4vpn") { echo(""); } + echo(")"); - echo(' | '); + echo(" | Multicast ("); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "prefixes_ipv4multicast") { echo(""); } + echo('IPv4'); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "prefixes_ipv4multicast") { echo(""); } + echo("|"); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "prefixes_ipv6multicast") { echo(""); } + echo('IPv6'); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "prefixes_ipv6multicast") { echo(""); } + echo(")"); - if ($graphs == "nographs") - { - echo(''); - } + echo(" | MAC ("); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "macaccounting_bits") { echo(""); } + echo('Bits'); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "macaccounting_bits") { echo(""); } + echo("|"); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "macaccounting_pkts") { echo(""); } + echo('Packets'); + if ($_GET['opta'] == "bgp" && $_GET['optc'] == "macaccounting_pkts") { echo(""); } + echo(")"); - if(!isset($_GET['optc'])) - { - echo(' No Graphs'); - } else { - echo(' No Graphs'); - } - - if ($graphs == "nographs") - { - echo(''); - } echo('
'); @@ -77,7 +89,7 @@ else echo(""); - echo(''); + echo(''); $i = "1"; @@ -122,11 +134,28 @@ else echo('"); + $af_query = mysql_query("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = '".$peer['device_id']."' AND bgpPeerIdentifier = '".$peer['bgpPeerIdentifier']."'"); + + unset($sep); + while ($afisafi = mysql_fetch_assoc($af_query)) + { + $afi = $afisafi['afi']; + $safi = $afisafi['safi']; + $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 = "
"; + $peer['afisafi'][$this_afisafi] = 1; ## Build a list of valid AFI/SAFI for this peer + } + unset($sep); + + echo(" - + - + + "); - if($graphs == "graphs") + unset($invalid); + switch ($_GET['optc']) { - $graph_array['height'] = "100"; - $graph_array['width'] = "216"; - $graph_array['to'] = $now; - $graph_array['id'] = $peer['bgpPeer_id']; - $graph_array['type'] = "bgp_updates"; + 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']; + } - echo('"); + if($peer['graph']) + { + $graph_array['height'] = "100"; + $graph_array['width'] = "220"; + $graph_array['to'] = $now; +# $graph_array['type'] = "bgp_" . $_GET['optc']; +# $graph_array['id'] = $peer['bgpPeer_id']; + echo('"); } $i++; diff --git a/html/pages/routing/cef.inc.php b/html/pages/routing/cef.inc.php new file mode 100644 index 000000000..e69de29bb diff --git a/html/pages/routing/ospf.inc.php b/html/pages/routing/ospf.inc.php new file mode 100644 index 000000000..e69de29bb diff --git a/html/pages/routing/overview.inc.php b/html/pages/routing/overview.inc.php new file mode 100644 index 000000000..1f08826ad --- /dev/null +++ b/html/pages/routing/overview.inc.php @@ -0,0 +1,26 @@ +'); + echo('
'.$type_text[$type].''); + include("pages/routing/overview/".mres($type).".inc.php"); + echo('
'); + echo(''); + } else { + $graph_title = $type_text[$type]; + $graph_type = "device_".$type; + include("includes/print-device-graph.php"); + } + } + } + + +?> diff --git a/html/pages/routing/overview/bgp.inc.php b/html/pages/routing/overview/bgp.inc.php index e69de29bb..82cf94a78 100644 --- a/html/pages/routing/overview/bgp.inc.php +++ b/html/pages/routing/overview/bgp.inc.php @@ -0,0 +1,13 @@ + + + Sessions: '.$total.' Up: '.$up.' Down: '.($total-$up) . ($stop != 0 ? ' ( Shutdown: '.$stop.' )' : '') . ' + '); + +?> diff --git a/includes/static-config.php b/includes/static-config.php index 3689323b4..76b7d647d 100644 --- a/includes/static-config.php +++ b/includes/static-config.php @@ -12,6 +12,7 @@ $config['afi']['ipv4']['multiicast'] = "IPv4 Multicast"; $config['afi']['ipv4']['vpn'] = "VPNv4"; $config['afi']['ipv6']['unicast'] = "IPv6"; $config['afi']['ipv6']['multicast'] = "IPv6 Multicast"; +$config['afi']['ipv4']['vpn'] = "VPNv6"; $config['os']['default']['over'][0]['graph'] = "device_processor"; $config['os']['default']['over'][0]['text'] = "Processor Usage";
Local addressPeer addressTypeRemote ASStateUptime
Local addressPeer addressTypeFamilyRemote ASStateUptime / Updates
" . $localaddresslink . "
".generate_device_link($peer, shorthost($peer['hostname']), 'routing/bgp/')."
->-> " . $peeraddresslink . "$peer_type$peer_type".$peer['afi']." AS" . $peer['bgpPeerRemoteAs'] . "
" . $peer['astext'] . "
" . $peer['bgpPeerAdminStatus'] . "
" . $peer['bgpPeerState'] . "
" .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
@@ -134,19 +163,47 @@ else " . format_si($peer['bgpPeerOutUpdates']) . "
'); + switch ($_GET['optc']) + { + 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 WHERE I.ipv4_address = '".$peer['bgpPeerIdentifier']."' AND M.mac = I.mac_address AND P.interface_id = M.interface_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['optc']; + } + } - include("includes/print-quadgraphs.inc.php"); + if ($_GET['optc'] == 'updates') { $peer['graph'] = 1; } - echo("
'); + include("includes/print-quadgraphs.inc.php"); + echo("