More updates to bgp polling/disco and webui

This commit is contained in:
laf
2015-06-09 14:30:19 +01:00
parent 702b75c0b7
commit 77b9adabc2
4 changed files with 19 additions and 18 deletions
+7
View File
@@ -168,10 +168,17 @@ else
$graph_type = "bgp_updates";
$local_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&type=" . $graph_type . "&from=".$config['time']['day']."&to=".$config['time']['now']."&width=500&height=150&&afi=ipv4&safi=unicast";
if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) {
$peer['bgpLocalAddr'] = Net_IPv6::compress($peer['bgpLocalAddr']);
}
$localaddresslink = "<span class=list-large><a href='device/device=" . $peer['device_id'] . "/tab=routing/proto=bgp/' onmouseover=\"return overlib('<img src=\'$local_daily_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer['bgpLocalAddr'] . "</a></span>";
$graph_type = "bgp_updates";
$peer_daily_url = "graph.php?id=" . $peer['bgpPeer_id'] . "&amp;type=" . $graph_type . "&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=500&amp;height=150";
if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE) {
$peer['bgpPeerIdentifier'] = Net_IPv6::compress($peer['bgpPeerIdentifier']);
}
$peeraddresslink = "<span class=list-large><a href='device/device=" . $peer['device_id'] . "/tab=routing/proto=bgp/' onmouseover=\"return overlib('<img src=\'$peer_daily_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">" . $peer['bgpPeerIdentifier'] . "</a></span>";
echo('<tr class="bgp"' . ($peer['alert'] ? ' bordercolor="#cc0000"' : '') . ($peer['disabled'] ? ' bordercolor="#cccccc"' : '') . ">");
+5
View File
@@ -37,6 +37,11 @@ if ($config['enable_bgp'])
list($ver, $peer) = explode(".", $peer,2);
}
list($peer_ip, $peer_as) = explode(" ", $peer);
if (strstr($peer_ip, ":")) {
$peer_ip_snmp = preg_replace("/:/", ' ', $peer_ip);
$peer_ip = preg_replace("/(\S+\s+\S+)\s/", '$1:', $peer_ip_snmp);
$peer_ip = str_replace('"','',str_replace(' ','',$peer_ip));
}
if ($peer && $peer_ip != "0.0.0.0")
{
-14
View File
@@ -1202,20 +1202,6 @@ function first_oid_match($device, $list) {
}
}
function ip_to_dec($ip) {
$return = '';
if (strstr($ip, ":")) {
$ipv6 = explode(':', $ip);
foreach ($ipv6 as $item) {
$return .= hexdec($item).'.';
}
$return = substr($return, 0, -1);
} else {
$return = $ip;
}
return $return;
}
function hex_to_ip($hex) {
$return = "";
if (filter_var($hex, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === FALSE && filter_var($hex, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE) {
+7 -4
View File
@@ -23,7 +23,7 @@ if ($config['enable_bgp'])
}
if ($peer2 === TRUE) {
$bgp_peer_ident = ip_to_dec($peer['bgpPeerIdentifier']);
$bgp_peer_ident = ipv62snmp($peer['bgpPeerIdentifier']);
if (strstr($peer['bgpPeerIdentifier'],":")) {
$ip_type = 2;
$ip_len = 16;
@@ -49,9 +49,11 @@ if ($config['enable_bgp'])
foreach ($peer_data_tmp[$ident] as $k => $v) {
if (strstr($k, "cbgpPeer2LocalAddr")) {
if ($ip_ver == 'ipv6') {
$v = preg_replace("/ /", ":", $v);
$v = str_replace('"','',$v);
$v = rtrim($v);
echo "YEAH $v\n";
$v = preg_replace("/(\S+\s+\S+)\s/", '$1:', $v);
$v = strtolower($v);
rtrim($v,":");
} else {
$v = hex_to_ip($v);
}
@@ -66,6 +68,7 @@ if ($config['enable_bgp'])
$peer_data = trim(`$peer_cmd`);
}
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
$bgpLocalAddr = str_replace('"','',str_replace(' ','',$bgpLocalAddr));
}
else
if ($device['os'] == "junos")
@@ -179,7 +182,7 @@ if ($config['enable_bgp'])
if ($debug) { echo("$afi $safi\n"); }
if ($device['os_group'] == "cisco") {
$bgp_peer_ident = ip_to_dec($peer['bgpPeerIdentifier']);
$bgp_peer_ident = ipv62snmp($peer['bgpPeerIdentifier']);
if (strstr($peer['bgpPeerIdentifier'], ":")) {
$ip_type = 2;
$ip_len = 16;