// Vendor specific IPv4/IPv6 BGP4 MIB if (!isset($vendor_peers)) { // Fetch BGP counters for some vendors $vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerIdentifier, $vendor_bgp, $vendor_mib, $vendor_mib_dir); $vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerRemoteAddr, $vendor_bgp, $vendor_mib, $vendor_mib_dir); //$vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerRemoteAddrType, $vendor_bgp, $vendor_mib, $vendor_mib_dir); $vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerLocalAddr, $vendor_bgp, $vendor_mib, $vendor_mib_dir); //$vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerIndex, $vendor_bgp, $vendor_mib, $vendor_mib_dir); $vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerState, $vendor_bgp, $vendor_mib, $vendor_mib_dir); $vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerAdminStatus, $vendor_bgp, $vendor_mib, $vendor_mib_dir); $vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerInUpdates, $vendor_bgp, $vendor_mib, $vendor_mib_dir); $vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerOutUpdates, $vendor_bgp, $vendor_mib, $vendor_mib_dir); $vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerInTotalMessages, $vendor_bgp, $vendor_mib, $vendor_mib_dir); $vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerOutTotalMessages, $vendor_bgp, $vendor_mib, $vendor_mib_dir); $vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerFsmEstablishedTime, $vendor_bgp, $vendor_mib, $vendor_mib_dir); $vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerInUpdateElapsedTime, $vendor_bgp, $vendor_mib, $vendor_mib_dir); // rewrite to pretty array. foreach ($vendor_bgp as $entry) { $v_ip = hex2ip($entry[$vendor_PeerRemoteAddr]); $entry[$vendor_PeerLocalAddr] = hex2ip($entry[$vendor_PeerLocalAddr]); $vendor_peers[$v_ip] = $entry; } } } if ($device['os_group'] == "cisco") { foreach ($cbgp_oids as $cbgp_oid) { $c_oid = $use_cisco_v2 ? str_replace('cbgpPeer', 'cbgpPeer2', $cbgp_oid) : $cbgp_oid; echo "{$c_oid} "; $c_prefixes = snmpwalk_cache_oid($device, $c_oid, $c_prefixes, 'CISCO-BGP4-MIB', mib_dirs('cisco')); } }
if ($device['bgpLocalAs']) { log_event('BGP ASN removed: AS' . $device['bgpLocalAs'], $device, 'bgp'); dbUpdate(array('bgpLocalAs' => 'NULL'), 'devices', 'device_id = ?', array($device['device_id'])); echo 'Removed ASN (' . $device['bgpLocalAs'] . "\n"; } # End if } # End if // Process discovered peers if (isset($peerlist)) { // Walk vendor oids if ($use_vendor) { $vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerRemoteAs, $vendor_bgp, $vendor_mib, $vendor_mib_dir, TRUE); $vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerRemoteAddr, $vendor_bgp, $vendor_mib, $vendor_mib_dir, TRUE); $vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerRemoteAddrType, $vendor_bgp, $vendor_mib, $vendor_mib_dir, TRUE); $vendor_bgp = snmpwalk_cache_oid_num2($device, $vendor_PeerIndex, $vendor_bgp, $vendor_mib, $vendor_mib_dir, TRUE); $vendor_counters = snmpwalk_cache_oid($device, $vendor_PrefixCountersSafi, array(), $vendor_mib, $vendor_mib_dir); } foreach ($peerlist as $peer) { $astext = get_astext($peer['as']); if (dbFetchCell('SELECT COUNT(*) FROM `bgpPeers` WHERE `device_id` = ? AND bgpPeerRemoteAddr = ?', array($device['device_id'], $peer['ip'])) < '1') { $params = array('device_id' => $device['device_id'], 'bgpPeerIdentifier' => $peer['id'], 'bgpPeerRemoteAddr' => $peer['ip'], 'bgpPeerLocalAddr' => $peer['local_ip'], 'bgpPeerRemoteAS' => $peer['as'], 'astext' => mres($astext)); dbInsert($params, 'bgpPeers'); echo '+'; } else { dbUpdate(array('bgpPeerRemoteAs' => $peer['as'], 'astext' => mres($astext), 'bgpPeerLocalAddr' => $peer['local_ip'], 'bgpPeerIdentifier' => $peer['id']), 'bgpPeers', 'device_id = ? AND bgpPeerRemoteAddr = ?', array($device['device_id'], $peer['ip'])); echo '.'; } } # Foreach // AFI/SAFI for specific vendors
} } if ($debug && $ip_data) { echo "CISCO-IETF-IP-MIB\n"; print_vars($ip_data); } } if (!count($ip_data)) { // Get IP addresses from IPV6-MIB $oids_ipv6 = array('ipv6AddrPfxLength', 'ipv6AddrType'); //.1.3.6.1.2.1.55.1.8.1.2.6105.16.254.128.0.0.0.0.0.0.2.26.169.255.254.23.134.97 = 64 //.1.3.6.1.2.1.55.1.8.1.3.6105.16.254.128.0.0.0.0.0.0.2.26.169.255.254.23.134.97 = stateful //Types: stateless(1), stateful(2), unknown(3) $oid_data = array(); foreach ($oids_ipv6 as $oid) { $oid_data = snmpwalk_cache_oid_num2($device, $oid, $oid_data, 'IPV6-MIB', mib_dirs()); } // Rewrite IPV6-MIB array foreach ($oid_data as $key => $entry) { list($ifIndex, $ip_address) = explode('.', $key, 2); $ip_address = snmp2ipv6($ip_address); if (!is_numeric($entry['ipv6AddrPfxLength'])) { $entry['ipv6AddrPfxLength'] = '128'; } if (is_ipv6_valid($ip_address, $entry['ipv6AddrPfxLength']) === FALSE) { continue; } $ip_data[$ifIndex][$ip_address]['ipAddressIfIndex'] = $ifIndex; $ip_data[$ifIndex][$ip_address]['ipAddressPrefix'] = $entry['ipv6AddrPfxLength']; $ip_data[$ifIndex][$ip_address]['ipAddressOrigin'] = $entry['ipv6AddrType']; }
// Also change $type print_cli_data('Device OS changed', $device['os'] . " -> {$os}", 1); log_event('OS changed: ' . $device['os'] . ' -> ' . $os, $device, 'device', $device['device_id'], 'warning'); dbUpdate(array('os' => $os), 'devices', '`device_id` = ?', array($device['device_id'])); $device['os'] = $os; $device['type'] = $type; } } // If enabled, check the sysORID table for supported MIBs if ($config['snmp']['snmp_sysorid']) { $sysORID_mibs = array(); $table_rows = array(); $advertised_mibs = array(); $capabilities_mibs = array(); print_cli_data_field('sysORID table'); $device_sysORID = snmpwalk_cache_oid_num2($device, 'sysORID', array(), 'SNMPv2-MIB'); $device_sysORID = snmpwalk_cache_oid($device, 'sysORDescr', $device_sysORID, 'SNMPv2-MIB', NULL, OBS_SNMP_ALL_MULTILINE); //print_vars($device_sysORID); foreach ($device_sysORID as $entry) { $advertised_mibs[] = $entry['sysORID']; if (preg_match('/AGENT-CAPABILITIES\\s+SUPPORTS\\s+(?<mib>\\S+)/', $entry['sysORDescr'], $matches)) { $mib = str_ireplace('ETHERLIKE-MIB', 'EtherLike-MIB', $matches['mib']); // Fix camel-case mib name // Collect AGENT-CAPABILITIES if MIB exist in definitions if (isset($config['mibs'][$mib]) && $mib != 'Printer-MIB') { $capabilities_mibs[$mib][] = $entry['sysORID']; } else { // This is just for info in output $capabilities_unused[$entry['sysORID']] = $mib; } }