Commit version 24.12.13800
This commit is contained in:
@ -4,61 +4,57 @@
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
$ip_version = 'ipv6';
|
||||
if (!safe_count($ip_data[$ip_version])) {
|
||||
// Get IP addresses from CISCO-IETF-IP-MIB
|
||||
//cIpAddressIfIndex.ipv6."20:01:04:70:00:15:00:bb:00:00:00:00:00:00:00:02" = 450
|
||||
//cIpAddressPrefix.ipv6."20:01:04:70:00:15:00:bb:00:00:00:00:00:00:00:02" = cIpAddressPfxOrigin.450.ipv6."20:01:04:70:00:15:00:bb:00:00:00:00:00:00:00:00".64
|
||||
//cIpAddressOrigin.ipv6."20:01:04:70:00:15:00:bb:00:00:00:00:00:00:00:02" = manual
|
||||
//Origins: 1:other, 2:manual, 4:dhcp, 5:linklayer, 6:random
|
||||
$flags = OBS_SNMP_ALL ^ OBS_QUOTES_STRIP;
|
||||
$oid_data = array();
|
||||
foreach (array('cIpAddressIfIndex', 'cIpAddressPrefix', 'cIpAddressType', 'cIpAddressOrigin') as $oid)
|
||||
{
|
||||
$oid_data = snmpwalk_cache_twopart_oid($device, $oid.'.'.$ip_version, $oid_data, 'CISCO-IETF-IP-MIB', NULL, $flags);
|
||||
if ($oid == 'cIpAddressIfIndex' && snmp_status() === FALSE)
|
||||
{
|
||||
break; // Stop walk, not exist table
|
||||
// Get IP addresses from CISCO-IETF-IP-MIB
|
||||
//cIpAddressIfIndex.ipv6."20:01:04:70:00:15:00:bb:00:00:00:00:00:00:00:02" = 450
|
||||
//cIpAddressPrefix.ipv6."20:01:04:70:00:15:00:bb:00:00:00:00:00:00:00:02" = cIpAddressPfxOrigin.450.ipv6."20:01:04:70:00:15:00:bb:00:00:00:00:00:00:00:00".64
|
||||
//cIpAddressOrigin.ipv6."20:01:04:70:00:15:00:bb:00:00:00:00:00:00:00:02" = manual
|
||||
//Origins: 1:other, 2:manual, 4:dhcp, 5:linklayer, 6:random
|
||||
$flags = OBS_SNMP_ALL ^ OBS_QUOTES_STRIP;
|
||||
$oid_data = [];
|
||||
foreach (['cIpAddressIfIndex', 'cIpAddressPrefix', 'cIpAddressType', 'cIpAddressOrigin'] as $oid) {
|
||||
$oid_data = snmpwalk_cache_twopart_oid($device, $oid . '.' . $ip_version, $oid_data, 'CISCO-IETF-IP-MIB', NULL, $flags);
|
||||
if ($oid == 'cIpAddressIfIndex' && snmp_status() === FALSE) {
|
||||
break; // Stop walk, not exist table
|
||||
}
|
||||
}
|
||||
}
|
||||
//print_vars($oid_data);
|
||||
//print_vars($oid_data);
|
||||
|
||||
// IPv6z
|
||||
if (isset($oid_data[$ip_version . 'z']))
|
||||
{
|
||||
$oid_data[$ip_version] = array_merge((array)$oid_data[$ip_version], $oid_data[$ip_version . 'z']);
|
||||
}
|
||||
// IPv6z
|
||||
if (isset($oid_data[$ip_version . 'z'])) {
|
||||
$oid_data[$ip_version] = array_merge((array)$oid_data[$ip_version], $oid_data[$ip_version . 'z']);
|
||||
}
|
||||
|
||||
// Rewrite CISCO-IETF-IP-MIB array
|
||||
foreach ($oid_data[$ip_version] as $ip_snmp => $entry)
|
||||
{
|
||||
$ip_address = hex2ip($ip_snmp);
|
||||
$ifIndex = $entry['cIpAddressIfIndex'];
|
||||
$tmp_prefix = explode('.', $entry['cIpAddressPrefix']);
|
||||
$entry['cIpAddressPrefix'] = end($tmp_prefix);
|
||||
// Rewrite CISCO-IETF-IP-MIB array
|
||||
foreach ($oid_data[$ip_version] as $ip_snmp => $entry) {
|
||||
$ip_address = hex2ip($ip_snmp);
|
||||
$ifIndex = $entry['cIpAddressIfIndex'];
|
||||
$tmp_prefix = explode('.', $entry['cIpAddressPrefix']);
|
||||
$entry['cIpAddressPrefix'] = end($tmp_prefix);
|
||||
|
||||
/*
|
||||
$ip_data[$ip_version][$ifIndex][$ip_address] = array('ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'prefix' => $entry['cIpAddressPrefix'],
|
||||
'type' => $entry['cIpAddressType'],
|
||||
'origin' => $entry['cIpAddressOrigin']);
|
||||
*/
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'prefix' => $entry['cIpAddressPrefix'],
|
||||
'type' => $entry['cIpAddressType'],
|
||||
'origin' => $entry['cIpAddressOrigin']
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
/*
|
||||
$ip_data[$ip_version][$ifIndex][$ip_address] = array('ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'prefix' => $entry['cIpAddressPrefix'],
|
||||
'type' => $entry['cIpAddressType'],
|
||||
'origin' => $entry['cIpAddressOrigin']);
|
||||
*/
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'prefix' => $entry['cIpAddressPrefix'],
|
||||
'type' => $entry['cIpAddressType'],
|
||||
'origin' => $entry['cIpAddressOrigin']
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
}
|
||||
|
||||
unset($ifIndex, $ip_address, $tmp_prefix, $oid_data, $flags);
|
||||
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2020 Observium Limited
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
@ -22,19 +22,16 @@
|
||||
$oids = snmp_get_multi_oid($device, 'agentNetworkIPAddress.0 agentNetworkSubnetMask.0 agentNetworkBurnedInMacAddress.0 agentNetworkMgmtVlan.0', [], $mib);
|
||||
print_debug_vars($oids);
|
||||
$entry = $oids[0];
|
||||
if ($port_id = get_port_id_by_ifDescr($device['device_id'], 'Vl'.$entry['agentNetworkMgmtVlan']))
|
||||
{
|
||||
// By Vlan
|
||||
$port = get_port_by_id_cache($port_id);
|
||||
$ifIndex = $port['ifIndex'];
|
||||
}
|
||||
elseif ($port_id = get_port_id_by_mac($device['device_id'], $entry['agentNetworkBurnedInMacAddress']))
|
||||
{
|
||||
// By MAC address
|
||||
$port = get_port_by_id_cache($port_id);
|
||||
$ifIndex = $port['ifIndex'];
|
||||
if ($port_id = get_port_id_by_ifDescr($device['device_id'], 'Vl' . $entry['agentNetworkMgmtVlan'])) {
|
||||
// By Vlan
|
||||
$port = get_port_by_id_cache($port_id);
|
||||
$ifIndex = $port['ifIndex'];
|
||||
} elseif ($port_id = get_port_id_by_mac($device['device_id'], $entry['agentNetworkBurnedInMacAddress'])) {
|
||||
// By MAC address
|
||||
$port = get_port_by_id_cache($port_id);
|
||||
$ifIndex = $port['ifIndex'];
|
||||
} else {
|
||||
$ifIndex = 0;
|
||||
$ifIndex = 0;
|
||||
}
|
||||
|
||||
$data = [
|
||||
@ -50,23 +47,23 @@ discover_add_ip_address($device, $mib, $data);
|
||||
// DNOS-SWITCHING-MIB::agentNetworkIpv6AddrStatus."........jOd....." = INTEGER: active(1)
|
||||
// DNOS-SWITCHING-MIB::agentNetworkIpv6AddressAutoConfig.0 = INTEGER: disable(2)
|
||||
// DNOS-SWITCHING-MIB::agentNetworkIpv6ConfigProtocol.0 = INTEGER: none(1)
|
||||
if (snmp_get_oid($device, 'agentNetworkIpv6AdminMode.0', $mib) === 'enabled')
|
||||
{
|
||||
// IPv6
|
||||
$oids = snmpwalk_cache_oid($device, 'agentNetworkIpv6AddrPrefixLength', [], $mib, NULL, OBS_SNMP_ALL_TABLE);
|
||||
$oids = snmpwalk_cache_oid($device, 'agentNetworkIpv6AddrStatus', $oids, $mib, NULL, OBS_SNMP_ALL_TABLE);
|
||||
print_debug_vars($oids);
|
||||
foreach ($oids as $ip_address => $entry)
|
||||
{
|
||||
if ($entry['agentNetworkIpv6AddrStatus'] !== 'active') { continue; }
|
||||
if (snmp_get_oid($device, 'agentNetworkIpv6AdminMode.0', $mib) === 'enabled') {
|
||||
// IPv6
|
||||
$oids = snmpwalk_cache_oid($device, 'agentNetworkIpv6AddrPrefixLength', [], $mib, NULL, OBS_SNMP_ALL_TABLE);
|
||||
$oids = snmpwalk_cache_oid($device, 'agentNetworkIpv6AddrStatus', $oids, $mib, NULL, OBS_SNMP_ALL_TABLE);
|
||||
print_debug_vars($oids);
|
||||
foreach ($oids as $ip_address => $entry) {
|
||||
if ($entry['agentNetworkIpv6AddrStatus'] !== 'active') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'prefix' => $entry['agentNetworkIpv6AddrPrefixLength']
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'prefix' => $entry['agentNetworkIpv6AddrPrefixLength']
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
}
|
||||
|
||||
// EOF
|
@ -5,9 +5,9 @@
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
@ -15,88 +15,87 @@
|
||||
|
||||
//if (!count($ip_data['ipv4']) && !count($ip_data['ipv6']))
|
||||
//{
|
||||
// Note, F5-BIGIP support IP-MIB, but on some firmware versions return not correct ifIndexes, this MIB uses correct indexes
|
||||
// Note, F5-BIGIP support IP-MIB, but on some firmware versions return not correct ifIndexes, this MIB uses correct indexes
|
||||
|
||||
$mib = 'F5-BIGIP-SYSTEM-MIB';
|
||||
$mib = 'F5-BIGIP-SYSTEM-MIB';
|
||||
|
||||
// Get IP addresses from F5-BIGIP-SYSTEM-MIB
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpAddrType."/Common/157.122.148.244" = INTEGER: ipv4(1)
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpAddrType."/Common/vlan2422HeFei-CU1G" = INTEGER: ipv4(1)
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpAddr."/Common/157.122.148.244" = Hex-STRING: 9D 7A 94 F4
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpAddr."/Common/vlan2422HeFei-CU1G" = Hex-STRING: 2A 9D 09 42
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpNetmask."/Common/vlan2422HeFei-CU1G" = Hex-STRING: FF FF FF F8
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpNetmask."/Common/vlan3682HeFei-CU2G" = Hex-STRING: FF FF FF F0
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpVlanName."/Common/157.122.148.244" = STRING: /Common/vlan3617
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpVlanName."/Common/vlan2422HeFei-CU1G" = STRING: /Common/vlan2422HeFei_CU1G
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpUnitId."/Common/157.122.148.244" = INTEGER: 1
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpUnitId."/Common/vlan2422HeFei-CU1G" = INTEGER: 0
|
||||
//$flags = OBS_SNMP_ALL ^ OBS_QUOTES_STRIP;
|
||||
$flags = OBS_SNMP_ALL;
|
||||
$oid_data = array();
|
||||
foreach (array('sysSelfIpAddrType', 'sysSelfIpVlanName', 'sysSelfIpUnitId', 'sysSelfIpAddr', 'sysSelfIpNetmask') as $oid)
|
||||
{
|
||||
// Get IP addresses from F5-BIGIP-SYSTEM-MIB
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpAddrType."/Common/157.122.148.244" = INTEGER: ipv4(1)
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpAddrType."/Common/vlan2422HeFei-CU1G" = INTEGER: ipv4(1)
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpAddr."/Common/157.122.148.244" = Hex-STRING: 9D 7A 94 F4
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpAddr."/Common/vlan2422HeFei-CU1G" = Hex-STRING: 2A 9D 09 42
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpNetmask."/Common/vlan2422HeFei-CU1G" = Hex-STRING: FF FF FF F8
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpNetmask."/Common/vlan3682HeFei-CU2G" = Hex-STRING: FF FF FF F0
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpVlanName."/Common/157.122.148.244" = STRING: /Common/vlan3617
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpVlanName."/Common/vlan2422HeFei-CU1G" = STRING: /Common/vlan2422HeFei_CU1G
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpUnitId."/Common/157.122.148.244" = INTEGER: 1
|
||||
//F5-BIGIP-SYSTEM-MIB::sysSelfIpUnitId."/Common/vlan2422HeFei-CU1G" = INTEGER: 0
|
||||
//$flags = OBS_SNMP_ALL ^ OBS_QUOTES_STRIP;
|
||||
$flags = OBS_SNMP_ALL;
|
||||
$oid_data = [];
|
||||
foreach (['sysSelfIpAddrType', 'sysSelfIpVlanName', 'sysSelfIpUnitId', 'sysSelfIpAddr', 'sysSelfIpNetmask'] as $oid) {
|
||||
$oid_data = snmpwalk_cache_oid($device, $oid, $oid_data, $mib, NULL, $flags);
|
||||
if ($oid == 'sysSelfIpAddrType' && $GLOBALS['snmp_status'] === FALSE)
|
||||
{
|
||||
break; // Stop walk, not exist table
|
||||
if ($oid == 'sysSelfIpAddrType' && $GLOBALS['snmp_status'] === FALSE) {
|
||||
break; // Stop walk, not exist table
|
||||
}
|
||||
}
|
||||
//print_vars($oid_data);
|
||||
}
|
||||
//print_vars($oid_data);
|
||||
|
||||
$query = 'SELECT `port_id`, `ifIndex`, `ifDescr` FROM `ports` WHERE `device_id` = ? AND `deleted` = ?';
|
||||
foreach (dbFetchRows($query, array($device['device_id'], 0)) as $entry)
|
||||
{
|
||||
$query = 'SELECT `port_id`, `ifIndex`, `ifDescr` FROM `ports` WHERE `device_id` = ? AND `deleted` = ?';
|
||||
foreach (dbFetchRows($query, [$device['device_id'], 0]) as $entry) {
|
||||
$ports_ifDescr[$entry['ifDescr']] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
// Rewrite F5-BIGIP-SYSTEM-MIB array
|
||||
foreach ($oid_data as $ip_name => $entry)
|
||||
{
|
||||
if ($entry['sysSelfIpUnitId'] != '0') { continue; } // Skip all except self Unit addresses
|
||||
// Rewrite F5-BIGIP-SYSTEM-MIB array
|
||||
foreach ($oid_data as $ip_name => $entry) {
|
||||
if ($entry['sysSelfIpUnitId'] != '0') {
|
||||
continue;
|
||||
} // Skip all except self Unit addresses
|
||||
|
||||
$ifName = $entry['sysSelfIpVlanName'];
|
||||
if (isset($ports_ifDescr[$ifName]))
|
||||
{
|
||||
$ifIndex = $ports_ifDescr[$ifName]['ifIndex'];
|
||||
$ip_version = $entry['sysSelfIpAddrType'];
|
||||
$ip_address = hex2ip($entry['sysSelfIpAddr']);
|
||||
$ip_mask = hex2ip($entry['sysSelfIpNetmask']);
|
||||
if (isset($ports_ifDescr[$ifName])) {
|
||||
$ifIndex = $ports_ifDescr[$ifName]['ifIndex'];
|
||||
$ip_version = $entry['sysSelfIpAddrType'];
|
||||
$ip_address = hex2ip($entry['sysSelfIpAddr']);
|
||||
$ip_mask = hex2ip($entry['sysSelfIpNetmask']);
|
||||
|
||||
if ($ip_version == 'ipv4')
|
||||
{
|
||||
$ip_mask_fix = explode('.', $ip_mask);
|
||||
if (empty($ip_mask) || count($ip_mask_fix) != 4)
|
||||
{
|
||||
$ip_mask = '255.255.255.255';
|
||||
if ($ip_version == 'ipv4') {
|
||||
$ip_mask_fix = explode('.', $ip_mask);
|
||||
if (empty($ip_mask) || count($ip_mask_fix) != 4) {
|
||||
$ip_mask = '255.255.255.255';
|
||||
}
|
||||
} else {
|
||||
// IPv6 - not tested
|
||||
$prefix = 0;
|
||||
$m = str_split($ip_mask);
|
||||
foreach ($m as $c) {
|
||||
if ($c == ":") {
|
||||
continue;
|
||||
}
|
||||
if ($c == "0") {
|
||||
break;
|
||||
}
|
||||
$bin = base_convert($c, 16, 2);
|
||||
$bin = trim($bin, "0");
|
||||
$prefix += strlen($bin);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// IPv6 - not tested
|
||||
$prefix = 0;
|
||||
$m = str_split($ip_mask);
|
||||
foreach ($m as $c) {
|
||||
if ($c == ":") { continue; }
|
||||
if ($c == "0") { break; }
|
||||
$bin = base_convert($c, 16, 2);
|
||||
$bin = trim($bin,"0");
|
||||
$prefix += strlen($bin);
|
||||
}
|
||||
}
|
||||
/*
|
||||
$ip_data[$ip_version][$ifIndex][$ip_address] = array('ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'mask' => $ip_mask,
|
||||
'prefix' => $prefix);
|
||||
*/
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'mask' => $ip_mask,
|
||||
'prefix' => $prefix
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
/*
|
||||
$ip_data[$ip_version][$ifIndex][$ip_address] = array('ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'mask' => $ip_mask,
|
||||
'prefix' => $prefix);
|
||||
*/
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'mask' => $ip_mask,
|
||||
'prefix' => $prefix
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
unset($ifName, $ifIndex, $ip_version, $ip_address, $ip_mask, $prefix);
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
unset($ports_ifDescr, $ifIndex, $ip_address, $ip_mask_fix, $oid_data, $flags);
|
||||
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
@ -32,126 +32,140 @@ $ip_version = 'ipv4';
|
||||
|
||||
$oid_data = snmpwalk_cache_oid($device, 'ipAdEntIfIndex', [], 'IP-MIB');
|
||||
if (snmp_status()) {
|
||||
$oid_data = snmpwalk_cache_oid($device, 'ipAdEntNetMask', $oid_data, 'IP-MIB');
|
||||
if (is_numeric(array_key_first($oid_data))) {
|
||||
// Some devices report just numbers instead ip address:
|
||||
// IP-MIB::ipAdEntAddr.0 = IpAddress: 0.0.0.0
|
||||
// IP-MIB::ipAdEntAddr.2130706433 = IpAddress: 127.0.0.1
|
||||
// IP-MIB::ipAdEntIfIndex.0 = INTEGER: 6620672
|
||||
// IP-MIB::ipAdEntIfIndex.2130706433 = INTEGER: 6625280
|
||||
// IP-MIB::ipAdEntNetMask.0 = IpAddress: 255.255.255.0
|
||||
// IP-MIB::ipAdEntNetMask.2130706433 = IpAddress: 255.255.255.255
|
||||
// IP-MIB::ipAdEntBcastAddr.0 = INTEGER: 1
|
||||
// IP-MIB::ipAdEntBcastAddr.2130706433 = INTEGER: 0
|
||||
$oid_data = snmpwalk_cache_oid($device, 'ipAdEntAddr', $oid_data, 'IP-MIB');
|
||||
}
|
||||
$oid_data = snmpwalk_cache_oid($device, 'ipAdEntNetMask', $oid_data, 'IP-MIB');
|
||||
if (is_numeric(array_key_first($oid_data))) {
|
||||
// Some devices report just numbers instead ip address:
|
||||
// IP-MIB::ipAdEntAddr.0 = IpAddress: 0.0.0.0
|
||||
// IP-MIB::ipAdEntAddr.2130706433 = IpAddress: 127.0.0.1
|
||||
// IP-MIB::ipAdEntIfIndex.0 = INTEGER: 6620672
|
||||
// IP-MIB::ipAdEntIfIndex.2130706433 = INTEGER: 6625280
|
||||
// IP-MIB::ipAdEntNetMask.0 = IpAddress: 255.255.255.0
|
||||
// IP-MIB::ipAdEntNetMask.2130706433 = IpAddress: 255.255.255.255
|
||||
// IP-MIB::ipAdEntBcastAddr.0 = INTEGER: 1
|
||||
// IP-MIB::ipAdEntBcastAddr.2130706433 = INTEGER: 0
|
||||
$oid_data = snmpwalk_cache_oid($device, 'ipAdEntAddr', $oid_data, 'IP-MIB');
|
||||
}
|
||||
print_debug_vars($oid_data);
|
||||
}
|
||||
|
||||
// Rewrite IP-MIB array
|
||||
foreach ($oid_data as $ip_address => $entry) {
|
||||
$ifIndex = $entry['ipAdEntIfIndex'];
|
||||
$ip_address_fix = explode('.', $ip_address);
|
||||
switch (count($ip_address_fix)) {
|
||||
case 4:
|
||||
break; // Just normal IPv4 address
|
||||
case 5:
|
||||
if ($device['os_group'] === 'bintec') {
|
||||
// Bintec Elmeg, see: http://jira.observium.org/browse/OBSERVIUM-1958
|
||||
unset($ip_address_fix[4]);
|
||||
} else {
|
||||
// Cisco Nexus, see: http://jira.observium.org/browse/OBSERVIUM-728
|
||||
unset($ip_address_fix[0]);
|
||||
}
|
||||
$ip_address = implode('.', $ip_address_fix);
|
||||
break;
|
||||
default:
|
||||
if (isset($entry['ipAdEntAddr']) && get_ip_version($entry['ipAdEntAddr'])) {
|
||||
$ip_address = $entry['ipAdEntAddr'];
|
||||
} else {
|
||||
print_debug("Detected unknown IPv4 address: $ip_address");
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
$ip_mask_fix = explode('.', $entry['ipAdEntNetMask']);
|
||||
if ($ip_mask_fix[0] < 255 && $ip_mask_fix[1] <= '255' && $ip_mask_fix[2] <= '255' && $ip_mask_fix[3] == '255')
|
||||
{
|
||||
// On some D-Link used wrong masks: 252.255.255.255, 0.255.255.255
|
||||
$entry['ipAdEntNetMask'] = $ip_mask_fix[3] . '.' . $ip_mask_fix[2] . '.' . $ip_mask_fix[1] . '.' . $ip_mask_fix[0];
|
||||
}
|
||||
if (empty($entry['ipAdEntNetMask']) || safe_count($ip_mask_fix) != 4)
|
||||
{
|
||||
$entry['ipAdEntNetMask'] = '255.255.255.255';
|
||||
}
|
||||
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'mask' => $entry['ipAdEntNetMask']
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
|
||||
// Get IP addresses from IP-MIB (new table, both IPv4/IPv6)
|
||||
$flags = OBS_SNMP_ALL ^ OBS_QUOTES_STRIP;
|
||||
$oid_data = array();
|
||||
foreach (array('ipAddressIfIndex', 'ipAddressType', 'ipAddressPrefix', 'ipAddressOrigin') as $oid)
|
||||
{
|
||||
$oid_data = snmpwalk_cache_twopart_oid($device, $oid, $oid_data, 'IP-MIB', NULL, $flags);
|
||||
if ($oid === 'ipAddressIfIndex' && !snmp_status()) {
|
||||
break; // Stop walk, not exist table
|
||||
}
|
||||
}
|
||||
//print_vars($oid_data);
|
||||
|
||||
// IPv4 addresses
|
||||
if (!safe_count($ip_data[$ip_version])) {
|
||||
//IP-MIB::ipAddressIfIndex.ipv4."198.237.180.2" = 8
|
||||
//IP-MIB::ipAddressPrefix.ipv4."198.237.180.2" = ipAddressPrefixOrigin.8.ipv4."198.237.180.2".32
|
||||
//IP-MIB::ipAddressOrigin.ipv4."198.237.180.2" = manual
|
||||
//Origins: 1:other, 2:manual, 4:dhcp, 5:linklayer, 6:random
|
||||
|
||||
// IPv4z (not sure, never seen)
|
||||
if (isset($oid_data[$ip_version . 'z'])) {
|
||||
$oid_data[$ip_version] = array_merge((array)$oid_data[$ip_version], $oid_data[$ip_version . 'z']);
|
||||
}
|
||||
|
||||
// Rewrite IP-MIB array
|
||||
foreach ($oid_data[$ip_version] as $ip_address => $entry) {
|
||||
if (in_array($entry['ipAddressType'], $GLOBALS['config']['ip-address']['ignore_type'])) { continue; } // Skip broadcasts
|
||||
//$ip_address = str_replace($ip_version.'.', '', $key);
|
||||
$ifIndex = $entry['ipAddressIfIndex'];
|
||||
|
||||
// ipAddressOrigin.ipv4.169.254.1.1.23 = manual
|
||||
$ifIndex = $entry['ipAdEntIfIndex'];
|
||||
$ip_address_fix = explode('.', $ip_address);
|
||||
$index_prefix = NULL;
|
||||
switch (safe_count($ip_address_fix)) {
|
||||
case 5:
|
||||
// get last number as prefix
|
||||
$index_prefix = array_pop($ip_address_fix);
|
||||
$ip_address = implode('.', $ip_address_fix);
|
||||
break;
|
||||
case 4:
|
||||
// Common, no need for changes
|
||||
break;
|
||||
default:
|
||||
print_debug("Unknown IP index: $ip_address");
|
||||
continue 2;
|
||||
switch (count($ip_address_fix)) {
|
||||
case 4:
|
||||
break; // Just normal IPv4 address
|
||||
case 5:
|
||||
if (in_array($device['os_group'], ['bintec', 'fortinet'])) {
|
||||
// Bintec Elmeg, see: http://jira.observium.org/browse/OBSERVIUM-1958
|
||||
// Same trouble on Fortinet devices
|
||||
// ipAdEntNetMask.10.3.250.111.1 = 255.255.255.255
|
||||
// ipAdEntNetMask.10.111.6.1.1 = 255.255.255.0
|
||||
unset($ip_address_fix[4]);
|
||||
} else {
|
||||
// Cisco Nexus, see: http://jira.observium.org/browse/OBSERVIUM-728
|
||||
unset($ip_address_fix[0]);
|
||||
}
|
||||
$ip_address = implode('.', $ip_address_fix);
|
||||
break;
|
||||
default:
|
||||
if (isset($entry['ipAdEntAddr']) && get_ip_version($entry['ipAdEntAddr'])) {
|
||||
$ip_address = $entry['ipAdEntAddr'];
|
||||
} else {
|
||||
print_debug("Detected unknown IPv4 address: $ip_address");
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
$tmp_prefix = explode('.', $entry['ipAddressPrefix']);
|
||||
$entry['ipAddressPrefix'] = end($tmp_prefix);
|
||||
if (!is_intnum($entry['ipAddressPrefix']) && is_intnum($index_prefix)) {
|
||||
$entry['ipAddressPrefix'] = $index_prefix;
|
||||
$ip_mask_fix = explode('.', $entry['ipAdEntNetMask']);
|
||||
if ($ip_mask_fix[0] < 255 && $ip_mask_fix[1] <= '255' && $ip_mask_fix[2] <= '255' && $ip_mask_fix[3] == '255') {
|
||||
// On some D-Link used wrong masks: 252.255.255.255, 0.255.255.255
|
||||
$entry['ipAdEntNetMask'] = $ip_mask_fix[3] . '.' . $ip_mask_fix[2] . '.' . $ip_mask_fix[1] . '.' . $ip_mask_fix[0];
|
||||
}
|
||||
if (empty($entry['ipAdEntNetMask']) || safe_count($ip_mask_fix) != 4) {
|
||||
$entry['ipAdEntNetMask'] = '255.255.255.255';
|
||||
}
|
||||
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'prefix' => $entry['ipAddressPrefix'],
|
||||
'type' => $entry['ipAddressType'],
|
||||
'origin' => $entry['ipAddressOrigin']
|
||||
'mask' => $entry['ipAdEntNetMask']
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
}
|
||||
|
||||
// Get IP addresses from IP-MIB (new table, both IPv4/IPv6)
|
||||
$flags = OBS_SNMP_ALL ^ OBS_QUOTES_STRIP;
|
||||
$oid_data = snmpwalk_cache_twopart_oid($device, 'ipAddressIfIndex', [], 'IP-MIB', NULL, $flags);
|
||||
if (snmp_status()) {
|
||||
foreach (['ipAddressType', 'ipAddressPrefix', 'ipAddressOrigin'] as $oid) {
|
||||
$oid_data = snmpwalk_cache_twopart_oid($device, $oid, $oid_data, 'IP-MIB', NULL, $flags);
|
||||
}
|
||||
print_debug_vars($oid_data);
|
||||
}
|
||||
|
||||
// IPv4 addresses
|
||||
if (safe_empty($ip_data[$ip_version])) {
|
||||
//IP-MIB::ipAddressIfIndex.ipv4."198.237.180.2" = 8
|
||||
//IP-MIB::ipAddressPrefix.ipv4."198.237.180.2" = ipAddressPrefixOrigin.8.ipv4."198.237.180.2".32
|
||||
//IP-MIB::ipAddressOrigin.ipv4."198.237.180.2" = manual
|
||||
//Origins: 1:other, 2:manual, 4:dhcp, 5:linklayer, 6:random
|
||||
|
||||
// Fortigate example:
|
||||
// IP-MIB::ipAddressIfIndex.ipv4."10.200.100.184".1 = INTEGER: 1
|
||||
// IP-MIB::ipAddressType.ipv4."10.200.100.184".1 = INTEGER: unicast(1)
|
||||
// IP-MIB::ipAddressPrefix.ipv4."10.200.100.184".1 = OID: SNMPv2-SMI::zeroDotZero.0
|
||||
// IP-MIB::ipAddressOrigin.ipv4."10.200.100.184".1 = INTEGER: manual(2)
|
||||
// IP-MIB::ipAddressStatus.ipv4."10.200.100.184".1 = INTEGER: preferred(1)
|
||||
|
||||
// IPv4z (not sure, never seen)
|
||||
if (isset($oid_data[$ip_version . 'z'])) {
|
||||
$oid_data[$ip_version] = array_merge((array)$oid_data[$ip_version], $oid_data[$ip_version . 'z']);
|
||||
}
|
||||
|
||||
// Rewrite IP-MIB array
|
||||
foreach ($oid_data[$ip_version] as $ip_address => $entry) {
|
||||
//$ip_address = str_replace($ip_version.'.', '', $key);
|
||||
$ifIndex = $entry['ipAddressIfIndex'];
|
||||
|
||||
// ipAddressOrigin.ipv4.169.254.1.1.23 = manual
|
||||
$ip_address_fix = explode('.', $ip_address);
|
||||
$index_prefix = NULL;
|
||||
switch (safe_count($ip_address_fix)) {
|
||||
case 5:
|
||||
// get last number as prefix
|
||||
$index_prefix = array_pop($ip_address_fix);
|
||||
if ($ifIndex == $index_prefix) {
|
||||
// Fortigate report ifIndex as last index part
|
||||
// See: https://jira.observium.org/browse/OBS-4341
|
||||
$index_prefix = NULL;
|
||||
}
|
||||
$ip_address = implode('.', $ip_address_fix);
|
||||
break;
|
||||
case 4:
|
||||
// Common, no need for changes
|
||||
break;
|
||||
default:
|
||||
print_debug("Unknown IP index: $ip_address");
|
||||
continue 2;
|
||||
}
|
||||
if (!str_contains($entry['ipAddressPrefix'], 'zeroDotZero')) {
|
||||
$tmp_prefix = explode('.', $entry['ipAddressPrefix']);
|
||||
$entry['ipAddressPrefix'] = end($tmp_prefix);
|
||||
unset($tmp_prefix);
|
||||
}
|
||||
if (!is_intnum($entry['ipAddressPrefix']) && is_intnum($index_prefix)) {
|
||||
$entry['ipAddressPrefix'] = $index_prefix;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'prefix' => $entry['ipAddressPrefix'],
|
||||
'type' => $entry['ipAddressType'],
|
||||
'origin' => $entry['ipAddressOrigin']
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -165,56 +179,63 @@ $ip_version = 'ipv6';
|
||||
|
||||
// IPv6z
|
||||
if (isset($oid_data[$ip_version . 'z'])) {
|
||||
$oid_data[$ip_version] = array_merge((array)$oid_data[$ip_version], $oid_data[$ip_version . 'z']);
|
||||
$oid_data[$ip_version] = array_merge((array)$oid_data[$ip_version], $oid_data[$ip_version . 'z']);
|
||||
}
|
||||
|
||||
// Rewrite IP-MIB array
|
||||
$check_ipv6_mib = FALSE; // Flag for additionally check IPv6-MIB
|
||||
foreach ($oid_data[$ip_version] as $ip_snmp => $entry) {
|
||||
if (str_contains($ip_snmp, '.')) {
|
||||
// incorrect indexes with prefix
|
||||
// ipAddressOrigin.ipv6.65152.0.0.0.521.4095.65033.51218.27 = manual
|
||||
$ip_address_fix = explode('.', $ip_snmp);
|
||||
$index_prefix = NULL;
|
||||
switch (count($ip_address_fix)) {
|
||||
case 9:
|
||||
// get last number as prefix
|
||||
$index_prefix = array_pop($ip_address_fix);
|
||||
//break;
|
||||
case 8:
|
||||
$ip_address_fix = array_map('dechex', $ip_address_fix);
|
||||
$ip_address = ip_uncompress(implode(':', $ip_address_fix));
|
||||
break;
|
||||
default:
|
||||
print_debug("Unknown IP index: $ip_snmp");
|
||||
continue 2;
|
||||
}
|
||||
} else {
|
||||
// Common address index
|
||||
$ip_address = hex2ip($ip_snmp);
|
||||
}
|
||||
$ifIndex = $entry['ipAddressIfIndex'];
|
||||
if ($entry['ipAddressPrefix'] === 'zeroDotZero') {
|
||||
// Additionally walk IPV6-MIB, especially in JunOS because they spit at world standards
|
||||
// See: http://jira.observium.org/browse/OBSERVIUM-1271
|
||||
$check_ipv6_mib = TRUE;
|
||||
} else {
|
||||
$tmp_prefix = explode('.', $entry['ipAddressPrefix']);
|
||||
$entry['ipAddressPrefix'] = end($tmp_prefix);
|
||||
}
|
||||
if (!is_intnum($entry['ipAddressPrefix']) && is_intnum($index_prefix)) {
|
||||
$entry['ipAddressPrefix'] = $index_prefix;
|
||||
$check_ipv6_mib = FALSE;
|
||||
}
|
||||
$ifIndex = $entry['ipAddressIfIndex'];
|
||||
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'prefix' => $entry['ipAddressPrefix'],
|
||||
'type' => $entry['ipAddressType'],
|
||||
'origin' => $entry['ipAddressOrigin']
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
if (str_contains($ip_snmp, '.')) {
|
||||
// incorrect indexes with prefix
|
||||
// ipAddressOrigin.ipv6.65152.0.0.0.521.4095.65033.51218.27 = manual
|
||||
$ip_address_fix = explode('.', $ip_snmp);
|
||||
$index_prefix = NULL;
|
||||
switch (count($ip_address_fix)) {
|
||||
case 9:
|
||||
// get last number as prefix
|
||||
$index_prefix = array_pop($ip_address_fix);
|
||||
if ($ifIndex == $index_prefix) {
|
||||
// Fortigate report ifIndex as last index part
|
||||
// See: https://jira.observium.org/browse/OBS-4341
|
||||
$index_prefix = NULL;
|
||||
}
|
||||
//break; // Do not break here!
|
||||
case 8:
|
||||
$ip_address_fix = array_map('dechex', $ip_address_fix);
|
||||
$ip_address = ip_uncompress(implode(':', $ip_address_fix));
|
||||
break;
|
||||
default:
|
||||
print_debug("Unknown IP index: $ip_snmp");
|
||||
continue 2;
|
||||
}
|
||||
} else {
|
||||
// Common address index
|
||||
$ip_address = hex2ip($ip_snmp);
|
||||
}
|
||||
|
||||
if (str_contains($entry['ipAddressPrefix'], 'zeroDotZero')) {
|
||||
// Additionally walk IPV6-MIB, especially in JunOS because they spit at world standards
|
||||
// See: http://jira.observium.org/browse/OBSERVIUM-1271
|
||||
$check_ipv6_mib = TRUE;
|
||||
} else {
|
||||
$tmp_prefix = explode('.', $entry['ipAddressPrefix']);
|
||||
$entry['ipAddressPrefix'] = end($tmp_prefix);
|
||||
}
|
||||
if (!is_intnum($entry['ipAddressPrefix']) && is_intnum($index_prefix)) {
|
||||
$entry['ipAddressPrefix'] = $index_prefix;
|
||||
$check_ipv6_mib = FALSE;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'prefix' => $entry['ipAddressPrefix'],
|
||||
'type' => $entry['ipAddressType'],
|
||||
'origin' => $entry['ipAddressOrigin']
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
|
||||
unset($ifIndex, $ip_address, $tmp_prefix, $oid_data);
|
||||
|
@ -4,50 +4,48 @@
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
$ip_version = 'ipv6';
|
||||
if ($check_ipv6_mib || !safe_count($ip_data[$ip_version])) { // Note, $check_ipv6_mib set in IP-MIB discovery
|
||||
|
||||
// Get IP addresses from IPV6-MIB
|
||||
//ipv6AddrPfxLength.20.254.192.0.0.0.0.0.0.0.10.0.0.0.0.0.4 = 64
|
||||
//ipv6AddrPfxLength.573.42.1.183.64.0.1.130.32.0.0.0.0.0.0.0.2 = 126
|
||||
//ipv6AddrType.20.254.192.0.0.0.0.0.0.0.10.0.0.0.0.0.4 = stateful
|
||||
//ipv6AddrType.573.42.1.183.64.0.1.130.32.0.0.0.0.0.0.0.2 = stateful
|
||||
//ipv6AddrAnycastFlag.20.254.192.0.0.0.0.0.0.0.10.0.0.0.0.0.4 = false
|
||||
//ipv6AddrAnycastFlag.573.42.1.183.64.0.1.130.32.0.0.0.0.0.0.0.2 = false
|
||||
//ipv6AddrStatus.20.254.192.0.0.0.0.0.0.0.10.0.0.0.0.0.4 = preferred
|
||||
//ipv6AddrStatus.573.42.1.183.64.0.1.130.32.0.0.0.0.0.0.0.2 = preferred
|
||||
//Types: stateless(1), stateful(2), unknown(3)
|
||||
$oid_data = snmpwalk_cache_twopart_oid($device, 'ipv6AddrEntry', array(), 'IPV6-MIB', NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
|
||||
//print_vars($oid_data);
|
||||
// Get IP addresses from IPV6-MIB
|
||||
//ipv6AddrPfxLength.20.254.192.0.0.0.0.0.0.0.10.0.0.0.0.0.4 = 64
|
||||
//ipv6AddrPfxLength.573.42.1.183.64.0.1.130.32.0.0.0.0.0.0.0.2 = 126
|
||||
//ipv6AddrType.20.254.192.0.0.0.0.0.0.0.10.0.0.0.0.0.4 = stateful
|
||||
//ipv6AddrType.573.42.1.183.64.0.1.130.32.0.0.0.0.0.0.0.2 = stateful
|
||||
//ipv6AddrAnycastFlag.20.254.192.0.0.0.0.0.0.0.10.0.0.0.0.0.4 = false
|
||||
//ipv6AddrAnycastFlag.573.42.1.183.64.0.1.130.32.0.0.0.0.0.0.0.2 = false
|
||||
//ipv6AddrStatus.20.254.192.0.0.0.0.0.0.0.10.0.0.0.0.0.4 = preferred
|
||||
//ipv6AddrStatus.573.42.1.183.64.0.1.130.32.0.0.0.0.0.0.0.2 = preferred
|
||||
//Types: stateless(1), stateful(2), unknown(3)
|
||||
$oid_data = snmpwalk_cache_twopart_oid($device, 'ipv6AddrEntry', [], 'IPV6-MIB', NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
|
||||
//print_vars($oid_data);
|
||||
|
||||
// Rewrite IPV6-MIB array
|
||||
foreach ($oid_data as $ifIndex => $entry1)
|
||||
{
|
||||
foreach ($entry1 as $ip_snmp => $entry)
|
||||
{
|
||||
$ip_address = snmp2ipv6($ip_snmp);
|
||||
// Rewrite IPV6-MIB array
|
||||
foreach ($oid_data as $ifIndex => $entry1) {
|
||||
foreach ($entry1 as $ip_snmp => $entry) {
|
||||
$ip_address = snmp2ipv6($ip_snmp);
|
||||
|
||||
/*
|
||||
$ip_data[$ip_version][$ifIndex][$ip_address] = array('ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'prefix' => $entry['ipv6AddrPfxLength'],
|
||||
'origin' => $entry['ipv6AddrType']);
|
||||
*/
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'prefix' => $entry['ipv6AddrPfxLength'],
|
||||
'origin' => $entry['ipv6AddrType']
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
/*
|
||||
$ip_data[$ip_version][$ifIndex][$ip_address] = array('ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'prefix' => $entry['ipv6AddrPfxLength'],
|
||||
'origin' => $entry['ipv6AddrType']);
|
||||
*/
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address,
|
||||
'prefix' => $entry['ipv6AddrPfxLength'],
|
||||
'origin' => $entry['ipv6AddrType']
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($ifIndex, $ip_address, $ip_snmp, $entry1, $oid_data);
|
||||
|
@ -4,57 +4,57 @@
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
if (!safe_count($ip_data['ipv4']) && !safe_count($ip_data['ipv6'])) {
|
||||
|
||||
// arubaos-cx not have any other place for fetch IP addresses
|
||||
// arubaos-cx not have any other place for fetch IP addresses
|
||||
|
||||
$oid_data = snmpwalk_cache_twopart_oid($device, 'lldpLocManAddrTable', [], 'LLDP-MIB', NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
|
||||
print_debug_vars($oid_data);
|
||||
$oid_data = snmpwalk_cache_twopart_oid($device, 'lldpLocManAddrTable', [], 'LLDP-MIB', NULL, OBS_SNMP_ALL_NUMERIC_INDEX);
|
||||
print_debug_vars($oid_data);
|
||||
|
||||
// lldpLocManAddrLen.1.4.10.30.3.12 = 4
|
||||
// lldpLocManAddrIfSubtype.1.4.10.30.3.12 = ifIndex
|
||||
// lldpLocManAddrIfId.1.4.10.30.3.12 = 326
|
||||
// lldpLocManAddrOID.1.4.10.30.3.12 = ifName.326
|
||||
// lldpLocManAddrLen.1.4.10.30.3.12 = 4
|
||||
// lldpLocManAddrIfSubtype.1.4.10.30.3.12 = ifIndex
|
||||
// lldpLocManAddrIfId.1.4.10.30.3.12 = 326
|
||||
// lldpLocManAddrOID.1.4.10.30.3.12 = ifName.326
|
||||
|
||||
|
||||
foreach ($oid_data as $ipv => $entry1) {
|
||||
if ((int)$ipv === 1) {
|
||||
$ip_version = 'ipv4';
|
||||
} elseif ((int)$ipv === 2) {
|
||||
$ip_version = 'ipv6';
|
||||
} else {
|
||||
// other types unknown
|
||||
continue;
|
||||
foreach ($oid_data as $ipv => $entry1) {
|
||||
if ((int)$ipv === 1) {
|
||||
$ip_version = 'ipv4';
|
||||
} elseif ((int)$ipv === 2) {
|
||||
$ip_version = 'ipv6';
|
||||
} else {
|
||||
// other types unknown
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($entry1 as $ip_snmp => $entry) {
|
||||
|
||||
[$len, $ip_snmp] = explode('.', $ip_snmp, 2);
|
||||
$ip_address = $ip_version === 'ipv6' ? snmp2ipv6($ip_snmp) : $ip_snmp;
|
||||
|
||||
if ($entry['lldpLocManAddrIfSubtype'] === 'ifIndex') {
|
||||
$ifIndex = $entry['lldpLocManAddrIfId'];
|
||||
} elseif ($port_id = get_port_id_by_ifDescr($device['device_id'], $entry['lldpLocManAddrIfId'])) {
|
||||
$port = get_port_by_id_cache($port_id);
|
||||
$ifIndex = $port['ifIndex'];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($entry1 as $ip_snmp => $entry) {
|
||||
|
||||
list($len, $ip_snmp) = explode('.', $ip_snmp, 2);
|
||||
$ip_address = $ip_version === 'ipv6' ? snmp2ipv6($ip_snmp) : $ip_snmp;
|
||||
|
||||
if ($entry['lldpLocManAddrIfSubtype'] === 'ifIndex') {
|
||||
$ifIndex = $entry['lldpLocManAddrIfId'];
|
||||
} elseif ($port_id = get_port_id_by_ifDescr($device['device_id'], $entry['lldpLocManAddrIfId'])) {
|
||||
$port = get_port_by_id_cache($port_id);
|
||||
$ifIndex = $port['ifIndex'];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip_address
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
}
|
||||
|
||||
unset($ifIndex, $ip_address, $ip_snmp, $entry1, $oid_data);
|
||||
unset($ifIndex, $ip_address, $ip_snmp, $entry1, $oid_data);
|
||||
}
|
||||
|
||||
// EOF
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
@ -14,41 +14,41 @@
|
||||
// NETAPP-MIB::nodeUuid.'WSLNetapp02-02' = STRING: 83eef39c-418e-11eb-b2bc-d039ea2575e5
|
||||
$nodes = [];
|
||||
foreach (snmpwalk_cache_oid($device, 'nodeUuid', [], $mib) as $node => $entry) {
|
||||
$nodes[$entry['nodeUuid']] = $node;
|
||||
$nodes[$entry['nodeUuid']] = $node;
|
||||
}
|
||||
print_vars($nodes);
|
||||
|
||||
//$flags = OBS_SNMP_ALL;
|
||||
$oid_data = [];
|
||||
foreach ([ 'logicalInterfaceNumericId', 'logicalInterfaceCurrNode', 'logicalInterfaceCurrPort',
|
||||
'logicalInterfaceAddress', 'logicalInterfaceNetmaskLength', 'logicalInterfaceRole' ] as $oid) {
|
||||
$oid_data = snmpwalk_cache_oid($device, $oid, $oid_data, $mib);
|
||||
if ($oid === 'logicalInterfaceNumericId' && !snmp_status()) {
|
||||
break; // Stop walk, not exist table
|
||||
}
|
||||
foreach (['logicalInterfaceNumericId', 'logicalInterfaceCurrNode', 'logicalInterfaceCurrPort',
|
||||
'logicalInterfaceAddress', 'logicalInterfaceNetmaskLength', 'logicalInterfaceRole'] as $oid) {
|
||||
$oid_data = snmpwalk_cache_oid($device, $oid, $oid_data, $mib);
|
||||
if ($oid === 'logicalInterfaceNumericId' && !snmp_status()) {
|
||||
break; // Stop walk, not exist table
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($oid_data as $index => $entry) {
|
||||
if (isset($nodes[$entry['logicalInterfaceCurrNode']])) {
|
||||
$ifDescr = $nodes[$entry['logicalInterfaceCurrNode']] . ':' . $entry['logicalInterfaceCurrPort'];
|
||||
if ($port_id = get_port_id_by_ifDescr($device, $ifDescr)) {
|
||||
$port = get_port_by_id_cache($port_id);
|
||||
$ifIndex = $port['ifIndex'];
|
||||
} else {
|
||||
print_debug("Port $ifDescr not found.");
|
||||
$ifIndex = $entry['logicalInterfaceNumericId'];
|
||||
//continue;
|
||||
if (isset($nodes[$entry['logicalInterfaceCurrNode']])) {
|
||||
$ifDescr = $nodes[$entry['logicalInterfaceCurrNode']] . ':' . $entry['logicalInterfaceCurrPort'];
|
||||
if ($port_id = get_port_id_by_ifDescr($device, $ifDescr)) {
|
||||
$port = get_port_by_id_cache($port_id);
|
||||
$ifIndex = $port['ifIndex'];
|
||||
} else {
|
||||
print_debug("Port $ifDescr not found.");
|
||||
$ifIndex = $entry['logicalInterfaceNumericId'];
|
||||
//continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $entry['logicalInterfaceAddress'],
|
||||
//'mask' => $entry['logicalInterfaceNetmask'],
|
||||
'prefix' => $entry['logicalInterfaceNetmaskLength'],
|
||||
'origin' => $entry['logicalInterfaceRole'],
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $entry['logicalInterfaceAddress'],
|
||||
//'mask' => $entry['logicalInterfaceNetmask'],
|
||||
'prefix' => $entry['logicalInterfaceNetmaskLength'],
|
||||
'origin' => $entry['logicalInterfaceRole'],
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
94
includes/discovery/ip-addresses/newtec-ip-mib.inc.php
Normal file
94
includes/discovery/ip-addresses/newtec-ip-mib.inc.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
$query = 'SELECT `port_id`, `ifIndex`, `ifDescr` FROM `ports` WHERE `device_id` = ? AND `deleted` = ?';
|
||||
$ports_ifDescr = [];
|
||||
foreach (dbFetchRows($query, [$device['device_id'], 0]) as $entry) {
|
||||
$ports_ifDescr[$entry['ifDescr']] = $entry;
|
||||
}
|
||||
//print_vars($ports_ifDescr);
|
||||
|
||||
// NEWTEC-IP-MIB::ntcIpMgmtInterfaceIpAddress.mgmt1 = STRING: 192.168.202.2/24
|
||||
// NEWTEC-IP-MIB::ntcIpMgmtInterfaceIpAddress.mgmt2 = STRING: 0.0.0.0/24
|
||||
// NEWTEC-IP-MIB::ntcIpMgmtInterfaceIpAddress.mgmt = STRING: 0.0.0.0/24
|
||||
// NEWTEC-IP-MIB::ntcIpMgmtInterfaceState.mgmt1 = INTEGER: on(1)
|
||||
// NEWTEC-IP-MIB::ntcIpMgmtInterfaceState.mgmt2 = INTEGER: off(0)
|
||||
// NEWTEC-IP-MIB::ntcIpMgmtInterfaceState.mgmt = INTEGER: off(0)
|
||||
// NEWTEC-IP-MIB::ntcIpMgmtInterfaceVirtualIpAddr.mgmt1 = STRING: 0.0.0.0/24
|
||||
// NEWTEC-IP-MIB::ntcIpMgmtInterfaceVirtualIpAddr.mgmt2 = STRING: 0.0.0.0/24
|
||||
// NEWTEC-IP-MIB::ntcIpMgmtInterfaceVirtualIpAddr.mgmt = STRING: 0.0.0.0/24
|
||||
// NEWTEC-IP-MIB::ntcMgmtGateway.0 = IpAddress: 192.168.202.1
|
||||
|
||||
foreach (snmpwalk_cache_oid($device, 'ntcIpMgmtInterfaceTable', [], $mib) as $ifDescr => $entry) {
|
||||
// if ($entry['ntcIpMgmtInterfaceState'] === 'off') {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
$ifIndex = $ports_ifDescr[$ifDescr]['ifIndex'] ?? 0;
|
||||
|
||||
[ $ip, $prefix ] = explode('/', $entry['ntcIpMgmtInterfaceIpAddress']);
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip,
|
||||
//'mask' => $ip_mask,
|
||||
'prefix' => $prefix
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
|
||||
[ $ip, $prefix ] = explode('/', $entry['ntcIpMgmtInterfaceVirtualIpAddr']);
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip,
|
||||
//'mask' => $ip_mask,
|
||||
'prefix' => $prefix
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
|
||||
// NEWTEC-IP-MIB::ntcDataInterfaceIpAddress.data1 = STRING: 0.0.0.0/24
|
||||
// NEWTEC-IP-MIB::ntcDataInterfaceIpAddress.data2 = STRING: 0.0.0.0/24
|
||||
// NEWTEC-IP-MIB::ntcDataInterfaceIpAddress.data = STRING: 0.0.0.0/24
|
||||
// NEWTEC-IP-MIB::ntcDataInterfaceState.data1 = INTEGER: off(0)
|
||||
// NEWTEC-IP-MIB::ntcDataInterfaceState.data2 = INTEGER: off(0)
|
||||
// NEWTEC-IP-MIB::ntcDataInterfaceState.data = INTEGER: on(1)
|
||||
// NEWTEC-IP-MIB::ntcDataInterfaceFysIpAddress.data1 = STRING: 0.0.0.0/24
|
||||
// NEWTEC-IP-MIB::ntcDataInterfaceFysIpAddress.data2 = STRING: 0.0.0.0/24
|
||||
// NEWTEC-IP-MIB::ntcDataInterfaceFysIpAddress.data = STRING: 10.252.10.5/29
|
||||
// NEWTEC-IP-MIB::ntcDataGateway.0 = IpAddress: 10.252.10.6
|
||||
|
||||
foreach (snmpwalk_cache_oid($device, 'ntcDataInterfaceTable', [], $mib) as $ifDescr => $entry) {
|
||||
// if ($entry['ntcDataInterfaceState'] === 'off') {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
$ifIndex = $ports_ifDescr[$ifDescr]['ifIndex'] ?? 0;
|
||||
|
||||
[ $ip, $prefix ] = explode('/', $entry['ntcDataInterfaceIpAddress']);
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip,
|
||||
//'mask' => $ip_mask,
|
||||
'prefix' => $prefix
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
|
||||
[ $ip, $prefix ] = explode('/', $entry['ntcDataInterfaceFysIpAddress']);
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $ip,
|
||||
//'mask' => $ip_mask,
|
||||
'prefix' => $prefix
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
|
||||
// EOF
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
@ -36,30 +36,30 @@
|
||||
$ip_version = 'ipv4';
|
||||
if (!safe_count($ip_data[$ip_version])) {
|
||||
|
||||
$oids = snmpwalk_cache_twopart_oid($device, 'wanNetworkIpTable', [], 'PEPLINK-WAN');
|
||||
if (snmp_status()) {
|
||||
$oids_int = snmpwalk_cache_oid($device, 'wanName', [], 'PEPLINK-WAN');
|
||||
$oids = snmpwalk_cache_twopart_oid($device, 'wanNetworkIpTable', [], 'PEPLINK-WAN');
|
||||
if (snmp_status()) {
|
||||
$oids_int = snmpwalk_cache_oid($device, 'wanName', [], 'PEPLINK-WAN');
|
||||
|
||||
foreach ($oids as $wanid => $wan) {
|
||||
$ifIndex = 0;
|
||||
if (isset($oids_int[$wanid]) &&
|
||||
$port_id = get_port_id_by_ifDescr($device['device_id'], $oids_int[$wanid]['wanName'])) {
|
||||
$port = get_port_by_id_cache($port_id);
|
||||
$ifIndex = $port['ifIndex'];
|
||||
}
|
||||
foreach ($oids as $wanid => $wan) {
|
||||
$ifIndex = 0;
|
||||
if (isset($oids_int[$wanid]) &&
|
||||
$port_id = get_port_id_by_ifDescr($device['device_id'], $oids_int[$wanid]['wanName'])) {
|
||||
$port = get_port_by_id_cache($port_id);
|
||||
$ifIndex = $port['ifIndex'];
|
||||
}
|
||||
|
||||
foreach ($wan as $entry) {
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $entry['wanNetworkIpAddress'],
|
||||
'mask' => $entry['wanNetworkSubnetMask'],
|
||||
//'type' => $entry[''],
|
||||
'origin' => $entry['wanNetworkIpType']
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
foreach ($wan as $entry) {
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $entry['wanNetworkIpAddress'],
|
||||
'mask' => $entry['wanNetworkSubnetMask'],
|
||||
//'type' => $entry[''],
|
||||
'origin' => $entry['wanNetworkIpType']
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
@ -4,9 +4,9 @@
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
@ -24,17 +24,38 @@
|
||||
// SDX-ROOT-MIB::systemNetworkInterface.0 = STRING: "LA Management"
|
||||
|
||||
if ($data = snmp_get_multi_oid($device, 'systemSvmIPAddress.0 systemXenIPAddress.0 systemNetmask.0 systemNetworkInterface.0', [], 'SDX-ROOT-MIB')) {
|
||||
$entry = $data[0];
|
||||
$ifIndex = 0;
|
||||
if ($port_id = get_port_id_by_ifDescr($device['device_id'], $entry['systemNetworkInterface'])) {
|
||||
$port = get_port_by_id_cache($port_id);
|
||||
$ifIndex = $port['ifIndex'];
|
||||
} else {
|
||||
list($if) = explode(' ', $entry['systemNetworkInterface']);
|
||||
if ($port_id = get_port_id_by_ifDescr($device['device_id'], "$if/1")) {
|
||||
$port = get_port_by_id_cache($port_id);
|
||||
$ifIndex = $port['ifIndex'];
|
||||
$entry = $data[0];
|
||||
$ifIndex = 0;
|
||||
if ($port_id = get_port_id_by_ifDescr($device['device_id'], $entry['systemNetworkInterface'])) {
|
||||
$port = get_port_by_id_cache($port_id);
|
||||
$ifIndex = $port['ifIndex'];
|
||||
} else {
|
||||
[$if] = explode(' ', $entry['systemNetworkInterface']);
|
||||
if ($port_id = get_port_id_by_ifDescr($device['device_id'], "$if/1")) {
|
||||
$port = get_port_by_id_cache($port_id);
|
||||
$ifIndex = $port['ifIndex'];
|
||||
}
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $entry['systemXenIPAddress'],
|
||||
'mask' => $entry['systemNetmask'],
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
|
||||
if ($port_id = get_port_id_by_ifDescr($device['device_id'], "$if/2")) {
|
||||
$port = get_port_by_id_cache($port_id);
|
||||
$ifIndex = $port['ifIndex'];
|
||||
}
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $entry['systemSvmIPAddress'],
|
||||
'mask' => $entry['systemNetmask'],
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $entry['systemXenIPAddress'],
|
||||
@ -42,33 +63,12 @@ if ($data = snmp_get_multi_oid($device, 'systemSvmIPAddress.0 systemXenIPAddress
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
|
||||
if ($port_id = get_port_id_by_ifDescr($device['device_id'], "$if/2")) {
|
||||
$port = get_port_by_id_cache($port_id);
|
||||
$ifIndex = $port['ifIndex'];
|
||||
}
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $entry['systemSvmIPAddress'],
|
||||
'mask' => $entry['systemNetmask'],
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $entry['systemXenIPAddress'],
|
||||
'mask' => $entry['systemNetmask'],
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
|
||||
$data = [
|
||||
'ifIndex' => $ifIndex,
|
||||
'ip' => $entry['systemSvmIPAddress'],
|
||||
'mask' => $entry['systemNetmask'],
|
||||
];
|
||||
discover_add_ip_address($device, $mib, $data);
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
Reference in New Issue
Block a user