Fix missing PoE port graphs for Cisco Catalyst 9K (#11698)

* Fix missing PoE port graphs for Cisco Catalyst 9K

* Reworked code: 2 assignments, added tests

* Simplify code

Checking the MIBs...
CISCO-POWER-ETHERNET-EXT-MIB: AUGMENTS { pethPsePortEntry  } 
POWER-ETHERNET-MIB: INDEX { pethPsePortGroupIndex , pethPsePortIndex  }

This means cpeExtPsePortEntry is always indexed by exactly 2 values.  No point in populating slot.subslot.port

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
Albert Siersema
2020-06-05 05:10:06 +02:00
committed by GitHub
parent e26498ad91
commit cd362b7983
3 changed files with 47831 additions and 2 deletions

View File

@@ -333,8 +333,13 @@ if (Config::get('enable_ports_poe')) {
$ifTable_ifDescr = snmpwalk_cache_oid($device, 'ifDescr', [], 'IF-MIB');
$port_ent_to_if = [];
foreach ($ifTable_ifDescr as $if_index => $if_descr) {
if (preg_match('/^[[:alpha:]]+ethernet([0-9\/.]+)$/i', $if_descr['ifDescr'], $matches)) {
$port_ent_to_if[str_replace('/', '.', $matches[1])] = ['portIfIndex' => $if_index];
/*
The ...EthernetX/Y/Z SNMP entries on Catalyst 9x00 iosxe
are cpeExtStuff.X.Z instead of cpeExtStuff.X.Y.Z
We need to ignore the middle subslot number so this is slot.port
*/
if (preg_match('/^[a-z]+ethernet(\d+)\/(\d+)(?:\/(\d+))?$/i', $if_descr['ifDescr'], $matches)) {
$port_ent_to_if[$matches[1] . '.' . ($matches[3] ?: $matches[2])] = ['portIfIndex' => $if_index];
}
}
}

34817
tests/data/iosxe_c9400.json Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff