Fixed missing PoE graphs for Cisco devices (#11087)

* Fixed missing PoE graphs for Cisco devices where portIfIndex can't be retrieved from CISCO-STACK-MIB

* Codeclimate & Travis error corrections

Co-authored-by: PipoCanaja <38363551+PipoCanaja@users.noreply.github.com>
This commit is contained in:
Albert Siersema
2020-02-01 11:01:36 +01:00
committed by GitHub
parent 36388e25ea
commit 398d5fe2b7

View File

@@ -326,8 +326,18 @@ if (Config::get('enable_ports_poe')) {
if ($device['os'] == 'ios' || $device['os'] == 'iosxe') {
echo 'cpeExtPsePortEntry';
$port_stats_poe = snmpwalk_cache_oid($device, 'cpeExtPsePortEntry', array(), 'CISCO-POWER-ETHERNET-EXT-MIB');
$port_ent_to_if = snmpwalk_cache_oid($device, 'portIfIndex', array(), 'CISCO-STACK-MIB');
$port_stats_poe = snmpwalk_cache_oid($device, 'cpeExtPsePortEntry', [], 'CISCO-POWER-ETHERNET-EXT-MIB');
$port_ent_to_if = snmpwalk_cache_oid($device, 'portIfIndex', [], 'CISCO-STACK-MIB');
if (!$port_ent_to_if) {
$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];
}
}
}
foreach ($port_stats_poe as $p_index => $p_stats) {
//We replace the ENTITY EntIndex by the IfIndex using the portIfIndex table (stored in $port_ent_to_if).