Skip to content

Commit

Permalink
Fix cbgp data
Browse files Browse the repository at this point in the history
  • Loading branch information
murrant committed Dec 5, 2024
1 parent 2263926 commit 3b18d71
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions includes/polling/bgp-peers.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
$generic = false;
if ($device['os'] == 'junos') {
$peer_data_check = SnmpQuery::mibDir('junos')->enumStrings()->abortOnFailure()->walk([
'BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerIndex',
'BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerState',
'BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerStatus',
'BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerInUpdates',
Expand Down Expand Up @@ -115,12 +116,12 @@
foreach ($peer_data_check as $peers => $jnx_peer_data) {
$exploded_ip = explode('.', $peers);
$ip_offset = count($exploded_ip) > 30 ? -16 : -4;
$tmp_peer_ip = Oid::of(implode('.', array_slice($exploded_ip, $ip_offset)))->toIp()->compressed();
$tmp_peer_ip = Oid::of(implode('.', array_slice($exploded_ip, $ip_offset)))->toIp()->uncompressed();
$junos[$tmp_peer_ip] = $jnx_peer_data;
}
}

$address = $peer_ip->compressed();
$address = $peer_ip->uncompressed();
$peer_data = [
'bgpPeerState' => $junos[$address]['BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerState'] ?? null,
'bgpPeerAdminStatus' => $junos[$address]['BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerStatus'] ?? null,
Expand Down Expand Up @@ -640,7 +641,8 @@
])->table(3);
}

$current_peer_data = $j_prefixes[$junos[(string) $peer_ip]['index']][$afi][$safis[$safi]];
$jnxPeerIndex = $junos[$peer_ip->uncompressed()]['BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerIndex'];
$current_peer_data = $j_prefixes[$jnxPeerIndex][$afi][$safis[$safi]];
$cbgpPeerAcceptedPrefixes = $current_peer_data['BGP4-V2-MIB-JUNIPER::jnxBgpM2PrefixInPrefixesAccepted'];
$cbgpPeerDeniedPrefixes = $current_peer_data['BGP4-V2-MIB-JUNIPER::jnxBgpM2PrefixInPrefixesRejected'];
$cbgpPeerAdvertisedPrefixes = $current_peer_data['BGP4-V2-MIB-JUNIPER::jnxBgpM2PrefixOutPrefixes'];
Expand Down

0 comments on commit 3b18d71

Please sign in to comment.