mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Updates
This commit is contained in:
@@ -33,7 +33,9 @@ if ($config['enable_bgp'])
|
|||||||
|
|
||||||
foreach (explode("\n", $peers) as $peer)
|
foreach (explode("\n", $peers) as $peer)
|
||||||
{
|
{
|
||||||
list($ver, $peer) = explode(".", $peer,2);
|
if ($peer2 === TRUE) {
|
||||||
|
list($ver, $peer) = explode(".", $peer,2);
|
||||||
|
}
|
||||||
list($peer_ip, $peer_as) = explode(" ", $peer);
|
list($peer_ip, $peer_as) = explode(" ", $peer);
|
||||||
|
|
||||||
if ($peer && $peer_ip != "0.0.0.0")
|
if ($peer && $peer_ip != "0.0.0.0")
|
||||||
|
@@ -1202,8 +1202,7 @@ function first_oid_match($device, $list) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ip_to_hex($ip) {
|
function ip_to_dec($ip) {
|
||||||
|
|
||||||
$return = '';
|
$return = '';
|
||||||
if (strstr($ip, ":")) {
|
if (strstr($ip, ":")) {
|
||||||
$ipv6 = explode(':', $ip);
|
$ipv6 = explode(':', $ip);
|
||||||
@@ -1216,3 +1215,19 @@ function ip_to_hex($ip) {
|
|||||||
}
|
}
|
||||||
return $return;
|
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) {
|
||||||
|
$hex_exp = explode(' ', $hex);
|
||||||
|
foreach ($hex_exp as $item) {
|
||||||
|
if (!empty($item) && $item != "\"") {
|
||||||
|
$return .= hexdec($item).'.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$return = substr($return, 0, -1);
|
||||||
|
} else {
|
||||||
|
$return = $ip;
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
@@ -23,7 +23,7 @@ if ($config['enable_bgp'])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($peer2 === TRUE) {
|
if ($peer2 === TRUE) {
|
||||||
$bgp_peer_ip = ip_to_hex($peer['bgpPeerIdentifier']);
|
$bgp_peer_ident = ip_to_dec($peer['bgpPeerIdentifier']);
|
||||||
if (strstr($peer['bgpPeerIdentifier'],":")) {
|
if (strstr($peer['bgpPeerIdentifier'],":")) {
|
||||||
$ip_type = 2;
|
$ip_type = 2;
|
||||||
$ip_len = 16;
|
$ip_len = 16;
|
||||||
@@ -33,7 +33,7 @@ if ($config['enable_bgp'])
|
|||||||
$ip_len = 4;
|
$ip_len = 4;
|
||||||
$ip_ver = 'ipv4';
|
$ip_ver = 'ipv4';
|
||||||
}
|
}
|
||||||
$peer_identifier = $ip_type . '.' . $ip_len . '.' . $bgp_peer_ip;
|
$peer_identifier = $ip_type . '.' . $ip_len . '.' . $bgp_peer_ident;
|
||||||
$peer_data_tmp = snmp_get_multi($device,
|
$peer_data_tmp = snmp_get_multi($device,
|
||||||
" cbgpPeer2State.". $peer_identifier .
|
" cbgpPeer2State.". $peer_identifier .
|
||||||
" cbgpPeer2AdminStatus.". $peer_identifier .
|
" cbgpPeer2AdminStatus.". $peer_identifier .
|
||||||
@@ -47,6 +47,15 @@ if ($config['enable_bgp'])
|
|||||||
$ident = "$ip_ver.\"".$peer['bgpPeerIdentifier'].'"';
|
$ident = "$ip_ver.\"".$peer['bgpPeerIdentifier'].'"';
|
||||||
unset($peer_data);
|
unset($peer_data);
|
||||||
foreach ($peer_data_tmp[$ident] as $k => $v) {
|
foreach ($peer_data_tmp[$ident] as $k => $v) {
|
||||||
|
if (strstr($k, "cbgpPeer2LocalAddr")) {
|
||||||
|
if ($ip_ver == 'ipv6') {
|
||||||
|
$v = preg_replace("/ /", ":", $v);
|
||||||
|
$v = strtolower($v);
|
||||||
|
rtrim($v,":");
|
||||||
|
} else {
|
||||||
|
$v = hex_to_ip($v);
|
||||||
|
}
|
||||||
|
}
|
||||||
$peer_data .= "$v\n";
|
$peer_data .= "$v\n";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -170,8 +179,7 @@ if ($config['enable_bgp'])
|
|||||||
if ($debug) { echo("$afi $safi\n"); }
|
if ($debug) { echo("$afi $safi\n"); }
|
||||||
|
|
||||||
if ($device['os_group'] == "cisco") {
|
if ($device['os_group'] == "cisco") {
|
||||||
|
$bgp_peer_ident = ip_to_dec($peer['bgpPeerIdentifier']);
|
||||||
$bgp_peer_ip = ip_to_hex($peer['bgpPeerIdentifier']);
|
|
||||||
if (strstr($peer['bgpPeerIdentifier'], ":")) {
|
if (strstr($peer['bgpPeerIdentifier'], ":")) {
|
||||||
$ip_type = 2;
|
$ip_type = 2;
|
||||||
$ip_len = 16;
|
$ip_len = 16;
|
||||||
@@ -189,11 +197,10 @@ if ($config['enable_bgp'])
|
|||||||
} elseif ($peer_afi['safi'] == "vpn") {
|
} elseif ($peer_afi['safi'] == "vpn") {
|
||||||
$ip_cast = 128;
|
$ip_cast = 128;
|
||||||
}
|
}
|
||||||
$check = snmp_get($device,"cbgpPeer2AcceptedPrefixes.".$ip_type.'.'.$ip_len.'.'.$bgp_peer_ip.'.'.$ip_type.'.'.$ip_cast,"","CISCO-BGP4-MIB", $config['mibdir']);
|
$check = snmp_get($device,"cbgpPeer2AcceptedPrefixes.".$ip_type.'.'.$ip_len.'.'.$bgp_peer_ident.'.'.$ip_type.'.'.$ip_cast,"","CISCO-BGP4-MIB", $config['mibdir']);
|
||||||
|
|
||||||
if(!empty($check)) {
|
if(!empty($check)) {
|
||||||
|
$cgp_peer_identifier = $ip_type . '.' . $ip_len . '.' . $bgp_peer_ident . '.' . $ip_type . '.' . $ip_cast;
|
||||||
$cgp_peer_identifier = $ip_type . '.' . $ip_len . '.' . $bgp_peer_ip . '.' . $ip_type . '.' . $ip_cast;
|
|
||||||
$cbgp_data_tmp = snmp_get_multi($device,
|
$cbgp_data_tmp = snmp_get_multi($device,
|
||||||
" cbgpPeer2AcceptedPrefixes.". $cgp_peer_identifier .
|
" cbgpPeer2AcceptedPrefixes.". $cgp_peer_identifier .
|
||||||
" cbgpPeer2DeniedPrefixes.". $cgp_peer_identifier .
|
" cbgpPeer2DeniedPrefixes.". $cgp_peer_identifier .
|
||||||
|
Reference in New Issue
Block a user