mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Re-added Junos prefix support :/
This commit is contained in:
@@ -186,6 +186,7 @@ if ($config['enable_bgp']) {
|
||||
if ($device['os_group'] == 'cisco' || $device['os'] == 'junos') {
|
||||
// Poll each AFI/SAFI for this peer (using CISCO-BGP4-MIB or BGP4-V2-JUNIPER MIB)
|
||||
$peer_afis = dbFetchRows('SELECT * FROM bgpPeers_cbgp WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['bgpPeerIdentifier']));
|
||||
print_r($peer_afis);
|
||||
foreach ($peer_afis as $peer_afi) {
|
||||
$afi = $peer_afi['afi'];
|
||||
$safi = $peer_afi['safi'];
|
||||
@@ -272,6 +273,45 @@ if ($config['enable_bgp']) {
|
||||
unset($cbgp_data);
|
||||
}//end if
|
||||
|
||||
if ($device['os'] == 'junos') {
|
||||
// Missing: cbgpPeerAdminLimit cbgpPeerPrefixThreshold cbgpPeerPrefixClearThreshold cbgpPeerSuppressedPrefixes cbgpPeerWithdrawnPrefixes
|
||||
$safis['unicast'] = 1;
|
||||
$safis['multicast'] = 2;
|
||||
|
||||
if (!isset($peerIndexes)) {
|
||||
$j_bgp = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PeerTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos');
|
||||
foreach ($j_bgp as $index => $entry) {
|
||||
switch ($entry['jnxBgpM2PeerRemoteAddrType']) {
|
||||
case 'ipv4':
|
||||
$ip = long2ip(hexdec($entry['jnxBgpM2PeerRemoteAddr']));
|
||||
$j_peerIndexes[$ip] = $entry['jnxBgpM2PeerIndex'];
|
||||
break;
|
||||
|
||||
case 'ipv6':
|
||||
$ip6 = trim(str_replace(' ', '', $entry['jnxBgpM2PeerRemoteAddr']), '"');
|
||||
$ip6 = substr($ip6, 0, 4).':'.substr($ip6, 4, 4).':'.substr($ip6, 8, 4).':'.substr($ip6, 12, 4).':'.substr($ip6, 16, 4).':'.substr($ip6, 20, 4).':'.substr($ip6, 24, 4).':'.substr($ip6, 28, 4);
|
||||
$ip6 = Net_IPv6::compress($ip6);
|
||||
$j_peerIndexes[$ip6] = $entry['jnxBgpM2PeerIndex'];
|
||||
break;
|
||||
|
||||
default:
|
||||
echo "PANIC: Don't know RemoteAddrType ".$entry['jnxBgpM2PeerRemoteAddrType']."!\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}//end if
|
||||
|
||||
$j_prefixes = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PrefixCountersTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos');
|
||||
|
||||
$cbgpPeerAcceptedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi.".$safis[$safi]]['jnxBgpM2PrefixInPrefixesAccepted'];
|
||||
$cbgpPeerDeniedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi.".$safis[$safi]]['jnxBgpM2PrefixInPrefixesRejected'];
|
||||
$cbgpPeerAdvertisedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi.".$safis[$safi]]['jnxBgpM2PrefixOutPrefixes'];
|
||||
|
||||
unset($j_prefixes);
|
||||
unset($j_bgp);
|
||||
unset($j_peerIndexes);
|
||||
}//end if
|
||||
|
||||
// FIXME THESE FIELDS DO NOT EXIST IN THE DATABASE!
|
||||
$update = 'UPDATE bgpPeers_cbgp SET';
|
||||
$peer['c_update']['AcceptedPrefixes'] = $cbgpPeerAcceptedPrefixes;
|
||||
|
||||
Reference in New Issue
Block a user