mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix cisco dbm sensors port link on discovery (NCS55A2) (#13965)
* Fix cisco dbm sensors port link on discovery (NCS55A2) dBm sensors were not linked to port on Cisco NCS55A2 platform (iosxr) causing false alarms triggered by optical modules in administratively shut down ports. * Delete iosxr_ncs55a2.json * Create iosxr_ncs55a2.json * Renew test/data/iosxr_ncs55a2.json * Delete and recreate test/data/iosxr_ncs55a2.json With command : ./scripts/save-test-data.php -o iosxr -v ncs55a2 -m os,ports,processors,mempools,sensors --------- Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
@@ -19,6 +19,15 @@ if ($device['os_group'] == 'cisco') {
|
||||
$entity_array = snmpwalk_cache_twopart_oid($device, 'entAliasMappingIdentifier', $entity_array, 'ENTITY-MIB:IF-MIB');
|
||||
}
|
||||
|
||||
$port_array = [];
|
||||
$port_array = snmpwalk_cache_multi_oid($device, 'ifName', $port_array, 'ENTITY-MIB:IF-MIB');
|
||||
$port_reverse_array = [];
|
||||
foreach ($port_array as $index => $port) {
|
||||
$port['ifIndex'] = $index;
|
||||
$port_reverse_array[$port['ifName']] = $port;
|
||||
}
|
||||
d_echo($port_reverse_array);
|
||||
|
||||
echo ' entSensorType';
|
||||
$oids = snmpwalk_cache_multi_oid($device, 'entSensorType', $oids, 'CISCO-ENTITY-SENSOR-MIB');
|
||||
echo ' entSensorScale';
|
||||
@@ -182,24 +191,37 @@ if ($device['os_group'] == 'cisco') {
|
||||
|
||||
if ($ok) {
|
||||
$phys_index = $entity_array[$index]['entPhysicalContainedIn'];
|
||||
$tmp_ifindex = 0;
|
||||
while ($phys_index != 0) {
|
||||
if ($index === $phys_index) {
|
||||
break;
|
||||
}
|
||||
if ($entity_array[$phys_index]['entPhysicalClass'] === 'port') {
|
||||
if (Str::contains($entity_array[$phys_index][0]['entAliasMappingIdentifier'], 'ifIndex.')) {
|
||||
[, $tmp_ifindex] = explode('.', $entity_array[$phys_index][0]['entAliasMappingIdentifier']);
|
||||
$tmp_port = get_port_by_index_cache($device['device_id'], $tmp_ifindex);
|
||||
if (is_array($tmp_port)) {
|
||||
$entPhysicalIndex = $tmp_ifindex;
|
||||
$entry['entSensorMeasuredEntity'] = 'ports';
|
||||
}
|
||||
|
||||
$entPhysicalClass = $entity_array[$phys_index]['entPhysicalClass'];
|
||||
$entPhysicalName = $entity_array[$phys_index]['entPhysicalName'];
|
||||
//either sensor is contained by a port class entity.
|
||||
if ($entPhysicalClass === 'port') {
|
||||
$entAliasMappingIdentifier = $entity_array[$phys_index][0]['entAliasMappingIdentifier'];
|
||||
if (Str::contains($entAliasMappingIdentifier, 'ifIndex.')) {
|
||||
[, $tmp_ifindex] = explode('.', $entAliasMappingIdentifier);
|
||||
}
|
||||
break;
|
||||
//or sensor entity has a parent entity with module class and entPhysicalName set to an existing ifName.
|
||||
} elseif ($entPhysicalClass === 'module' && array_key_exists($entPhysicalName, $port_reverse_array)) {
|
||||
$tmp_ifindex = $port_reverse_array[$entPhysicalName]['ifIndex'];
|
||||
break;
|
||||
} else {
|
||||
$phys_index = $entity_array[$phys_index]['entPhysicalContainedIn'];
|
||||
}
|
||||
}
|
||||
if ($tmp_ifindex != 0) {
|
||||
$tmp_port = get_port_by_index_cache($device['device_id'], $tmp_ifindex);
|
||||
if (is_array($tmp_port)) {
|
||||
$entPhysicalIndex = $tmp_ifindex;
|
||||
$entry['entSensorMeasuredEntity'] = 'ports';
|
||||
}
|
||||
}
|
||||
|
||||
discover_sensor($valid['sensor'], $type, $device, $oid, $index, 'cisco-entity-sensor', ucwords($descr), $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entry['entSensorMeasuredEntity'], null);
|
||||
//Cisco IOS-XR : add a fake sensor to graph as dbm
|
||||
if ($type == 'power' and $device['os'] == 'iosxr' and (preg_match('/power (R|T)x/i', $descr) or preg_match('/(R|T)x Power/i', $descr) or preg_match('/(R|T)x Lane/i', $descr))) {
|
||||
|
25759
tests/data/iosxr_ncs55a2.json
Normal file
25759
tests/data/iosxr_ncs55a2.json
Normal file
File diff suppressed because it is too large
Load Diff
10594
tests/snmpsim/iosxr_ncs55a2.snmprec
Normal file
10594
tests/snmpsim/iosxr_ncs55a2.snmprec
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user