$vendor_bgp = snmpwalk_cache_oid($device, $vendor_PeerIdentifier, $vendor_bgp, $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX); $vendor_bgp = snmpwalk_cache_oid($device, $vendor_PeerAdminStatus, $vendor_bgp, $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX); //print_vars($vendor_bgp); print_debug("{$vendor_mib} Peers: "); foreach ($vendor_bgp as $idx => $entry) { if (count($vendor_use_index)) { parse_bgp_peer_index($entry, $idx, $vendor_mib); } $peer_ip = hex2ip($entry[$vendor_PeerRemoteAddr]); $local_ip = hex2ip($entry[$vendor_PeerLocalAddr]); $peer_as = $entry[$vendor_PeerRemoteAs]; if ($peer_ip == '0.0.0.0') { $peer_ip = ''; } $peer = array('id' => $entry[$vendor_PeerIdentifier], 'local_ip' => $local_ip, 'ip' => $peer_ip, 'as' => $peer_as, 'admin_status' => $entry[$vendor_PeerAdminStatus]); if (!isset($p_list[$peer_ip][$peer_as]) && is_bgp_peer_valid($peer, $device)) { $p_list[$peer_ip][$peer_as] = 1; $peerlist[] = $peer; print_debug("Found peer IP: {$peer_ip} (AS{$peer_as}, LocalIP: {$local_ip})"); } } } else { $vendor_mib = FALSE; // Unset vendor_mib since not found on device } } # Vendors } else { echo "No BGP on host"; if (is_numeric($device['bgpLocalAs'])) { log_event('BGP ASN removed: AS' . $device['bgpLocalAs'], $device, 'bgp');
$vendor_bgp = snmpwalk_cache_oid($device, $vendor_PeerFsmEstablishedTime, $vendor_bgp, $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX); $vendor_bgp = snmpwalk_cache_oid($device, $vendor_PeerInUpdateElapsedTime, $vendor_bgp, $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX); // Collect founded peers and rewrite to pretty array. foreach ($vendor_bgp as $idx => $entry) { if (count($vendor_use_index)) { parse_bgp_peer_index($entry, $idx, $vendor_mib); } $peer_ip = hex2ip($entry[$vendor_PeerRemoteAddr]); //$entry[$vendor_PeerLocalAddr] = hex2ip($entry[$vendor_PeerLocalAddr]); $entry['idx'] = $idx; if ($peer_ip == '0.0.0.0') { $peer_ip = ''; } $peer_as = $entry[$vendor_PeerRemoteAs]; $peer = array('ip' => $peer_ip, 'as' => $peer_as, 'admin_status' => $entry[$vendor_PeerAdminStatus]); if (is_bgp_peer_valid($peer)) { $p_list[$peer_ip][$peer_as] = 1; $vendor_peers[$peer_ip][$peer_as] = $entry; } } // Fetch vendor specific counters $vendor_counters = snmpwalk_cache_oid($device, $vendor_PeerAcceptedPrefixes, array(), $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX); if ($vendor_PeerDeniedPrefixes != '') { $vendor_counters = snmpwalk_cache_oid($device, $vendor_PeerDeniedPrefixes, $vendor_counters, $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX); } $vendor_counters = snmpwalk_cache_oid($device, $vendor_PeerAdvertisedPrefixes, $vendor_counters, $vendor_mib, NULL, OBS_SNMP_ALL_NUMERIC_INDEX); } else { $vendor_mib = FALSE; } } echo PHP_EOL;