hasGlobalRead()) { include 'includes/error-no-perm.inc.php'; } else { $link_array = array( 'page' => 'routing', 'protocol' => 'bgp', ); print_optionbar_start('', ''); echo 'BGP » '; if (!$vars['type']) { $vars['type'] = 'all'; } if ($vars['type'] == 'all') { echo ""; } echo generate_link('All', $vars, array('type' => 'all')); if ($vars['type'] == 'all') { echo ''; } echo ' | '; if ($vars['type'] == 'internal') { echo ""; } echo generate_link('iBGP', $vars, array('type' => 'internal')); if ($vars['type'] == 'internal') { echo ''; } echo ' | '; if ($vars['type'] == 'external') { echo ""; } echo generate_link('eBGP', $vars, array('type' => 'external')); if ($vars['type'] == 'external') { echo ''; } echo ' | '; if ($vars['adminstatus'] == 'stop') { echo ""; echo generate_link('Shutdown', $vars, array('adminstatus' => null)); echo ''; } else { echo generate_link('Shutdown', $vars, array('adminstatus' => 'stop')); } echo ' | '; if ($vars['adminstatus'] == 'start') { echo ""; echo generate_link('Enabled', $vars, array('adminstatus' => null)); echo ''; } else { echo generate_link('Enabled', $vars, array('adminstatus' => 'start')); } echo ' | '; if ($vars['state'] == 'down') { echo ""; echo generate_link('Down', $vars, array('state' => null)); echo ''; } else { echo generate_link('Down', $vars, array('state' => 'down')); } // End BGP Menu if (!isset($vars['view'])) { $vars['view'] = 'details'; } echo '
'; if ($vars['view'] == 'details') { echo ""; } echo generate_link('No Graphs', $vars, array('view' => 'details', 'graph' => 'NULL')); if ($vars['view'] == 'details') { echo ''; } echo ' | '; if ($vars['graph'] == 'updates') { echo ""; } echo generate_link('Updates', $vars, array('view' => 'graphs', 'graph' => 'updates')); if ($vars['graph'] == 'updates') { echo ''; } echo ' | Prefixes: Unicast ('; if ($vars['graph'] == 'prefixes_ipv4unicast') { echo ""; $extra_sql = " AND `bgpPeerIdentifier` NOT LIKE '%:%'"; } echo generate_link('IPv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4unicast')); if ($vars['graph'] == 'prefixes_ipv4unicast') { echo ''; } echo '|'; if ($vars['graph'] == 'prefixes_ipv6unicast') { echo ""; $extra_sql = " AND `bgpPeerIdentifier` LIKE '%:%'"; } echo generate_link('IPv6', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6unicast')); if ($vars['graph'] == 'prefixes_ipv6unicast') { echo ''; } echo '|'; if ($vars['graph'] == 'prefixes_ipv4vpn') { echo ""; } echo generate_link('VPNv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4vpn')); if ($vars['graph'] == 'prefixes_ipv4vpn') { echo ''; } echo ')'; echo ' | Multicast ('; if ($vars['graph'] == 'prefixes_ipv4multicast') { echo ""; } echo generate_link('IPv4', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv4multicast')); if ($vars['graph'] == 'prefixes_ipv4multicast') { echo ''; } echo '|'; if ($vars['graph'] == 'prefixes_ipv6multicast') { echo ""; } echo generate_link('IPv6', $vars, array('view' => 'graphs', 'graph' => 'prefixes_ipv6multicast')); if ($vars['graph'] == 'prefixes_ipv6multicast') { echo ''; } echo ')'; echo ' | MAC ('; if ($vars['graph'] == 'macaccounting_bits') { echo ""; } echo generate_link('Bits', $vars, array('view' => 'graphs', 'graph' => 'macaccounting_bits')); if ($vars['graph'] == 'macaccounting_bits') { echo ''; } echo '|'; if ($vars['graph'] == 'macaccounting_pkts') { echo ""; } echo generate_link('Packets', $vars, array('view' => 'graphs', 'graph' => 'macaccounting_pkts')); if ($vars['graph'] == 'macaccounting_pkts') { echo ''; } echo ')'; echo '
'; print_optionbar_end(); echo ""; echo ''; if ($vars['type'] == 'external') { $where = 'AND D.bgpLocalAs != B.bgpPeerRemoteAs'; } elseif ($vars['type'] == 'internal') { $where = 'AND D.bgpLocalAs = B.bgpPeerRemoteAs'; } if ($vars['adminstatus'] == 'stop') { $where .= " AND (B.bgpPeerAdminStatus = 'stop')"; } elseif ($vars['adminstatus'] == 'start') { $where .= " AND (B.bgpPeerAdminStatus = 'start' || B.bgpPeerAdminStatus = 'running')"; } if ($vars['state'] == 'down') { $where .= " AND (B.bgpPeerState != 'established')"; } $peer_query = "SELECT * FROM `bgpPeers` AS `B`, `devices` AS `D` WHERE `B`.`device_id` = `D`.`device_id` $where $extra_sql ORDER BY `D`.`hostname`, `B`.`bgpPeerRemoteAs`, `B`.`bgpPeerIdentifier`"; foreach (dbFetchRows($peer_query) as $peer) { unset($alert, $bg_image); 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"; } } try { $peer_ip = new IPv6($peer['bgpLocalAddr']); } catch (InvalidIpException $e) { $peer_ip = $peer['bgpLocalAddr']; } try { $peer_ident = new IPv6($peer['bgpPeerIdentifier']); } catch (InvalidIpException $e) { $peer_ident = $peer['bgpPeerIdentifier']; } // display overlib graphs $graph_array = array(); $graph_array['type'] = 'bgp_updates'; $graph_array['id'] = $peer['bgpPeer_id']; $graph_array['to'] = $config['time']['now']; $graph_array['from'] = $config['time']['day']; $graph_array['height'] = '110'; $graph_array['width'] = $width; // Peer Address $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = '150'; $graph_array_zoom['width'] = '500'; $overlib_link = "device/device=".$peer['device_id']."/tab=routing/proto=bgp/"; $peeraddresslink = "".overlib_link($overlib_link, $peer_ident, generate_graph_tag($graph_array_zoom), null).""; // Local Address $graph_array['afi'] = 'ipv4'; $graph_array['safi'] = 'unicast'; $graph_array_zoom['afi'] = 'ipv4'; $graph_array_zoom['safi'] = 'unicast'; $overlib_link = "device/device=".$peer['device_id']."/tab=routing/proto=bgp/"; $localaddresslink = "".overlib_link($overlib_link, $peer_ip, generate_graph_tag($graph_array_zoom), null).""; 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 ' '; unset($invalid); switch ($vars['graph']) { case 'prefixes_ipv4unicast': case 'prefixes_ipv4multicast': case 'prefixes_ipv4vpn': case 'prefixes_ipv6unicast': case 'prefixes_ipv6multicast': list(,$afisafi) = explode('_', $vars['graph']); if (isset($peer['afisafi'][$afisafi])) { $peer['graph'] = 1; } // fall-through case 'updates': $graph_array['type'] = 'bgp_'.$vars['graph']; $graph_array['id'] = $peer['bgpPeer_id']; } switch ($vars['graph']) { 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.port_id = M.port_id AND D.device_id = P.device_id', array($peer['bgpPeerIdentifier'])); $database = rrd_name($device['hostname'], array('cip', $acc['ifIndex'], $acc['mac'])); if (is_array($acc) && is_file($database)) { $peer['graph'] = 1; $graph_array['id'] = $acc['ma_id']; $graph_array['type'] = $vars['graph']; } } if ($vars['graph'] == 'updates') { $peer['graph'] = 1; } if ($peer['graph']) { $graph_array['height'] = '100'; $graph_array['width'] = '218'; $graph_array['to'] = $config['time']['now']; echo ''; } }//end foreach echo '
Local addressPeer addressTypeFamilyRemote ASPeer descriptionStateUptime / Updates
'.$localaddresslink.'
'.generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp')).'
» '.$peeraddresslink." $peer_type ".$peer['afi'].' AS'.$peer['bgpPeerRemoteAs'].'
'.$peer['astext']."
".$peer['bgpPeerDescr']." ".$peer['bgpPeerAdminStatus']."
".$peer['bgpPeerState'].'
'.formatUptime($peer['bgpPeerFsmEstablishedTime'])."
Updates ".format_si($peer['bgpPeerInUpdates'])." ".format_si($peer['bgpPeerOutUpdates']).'
'; include 'includes/print-graphrow.inc.php'; echo '
'; }//end if