From 3b18d71914668fc4dda1351d7701931ef892d415 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Thu, 5 Dec 2024 12:51:20 -0600 Subject: [PATCH] Fix cbgp data --- includes/polling/bgp-peers.inc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php index 527e78df7656..6e198ba744c3 100644 --- a/includes/polling/bgp-peers.inc.php +++ b/includes/polling/bgp-peers.inc.php @@ -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', @@ -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, @@ -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'];