diff --git a/includes/polling/port-adsl.inc.php b/includes/polling/port-adsl.inc.php index e3567e26b5..901fb6d0b9 100644 --- a/includes/polling/port-adsl.inc.php +++ b/includes/polling/port-adsl.inc.php @@ -39,9 +39,9 @@ // adslAturPerfESs.1 = 0 seconds // adslAturPerfValidIntervals.1 = 0 // adslAturPerfInvalidIntervals.1 = 0 -if (isset($port_stats[$port_id]['adslLineCoding'])) { +if (isset($port_stats[$ifIndex]['adslLineCoding'])) { // Check to make sure Port data is cached. - $this_port = &$port_stats[$port_id]; + $this_port = &$port_stats[$ifIndex]; $rrdfile = get_port_rrdfile_path ($device['hostname'], $port_id, 'adsl'); diff --git a/includes/polling/port-etherlike.inc.php b/includes/polling/port-etherlike.inc.php index bf947b92db..ea8b044c2a 100644 --- a/includes/polling/port-etherlike.inc.php +++ b/includes/polling/port-etherlike.inc.php @@ -1,10 +1,10 @@ $port) { dbInsert(array('port_id' => $port_id), 'ports_statistics'); } - // Assure stable mapping - $port_stats[$ifIndex]['port_id'] = $port_id; + /** Assure stable bidirectional port mapping between DB and polled data + * + * Store the *current* ifIndex in the port info array containing all port information + * fetched from the database, as this is the only means we have to map ports_stats we + * just polled from the device to a port in $ports. All code below an includeed below + * will and has to map a port using it's ifIndex. + */ $ports[$port_id]['ifIndex'] = $ifIndex; + $port_stats[$ifIndex]['port_id'] = $port_id; } // Port vanished (mark as deleted) @@ -299,11 +305,12 @@ echo "\n"; // Loop ports in the DB and update where necessary foreach ($ports as $port) { $port_id = $port['port_id']; + $ifIndex = $port['ifIndex']; - echo 'Port ' . $port['ifName'] . ': ' . $port['ifDescr'] . '(' . $port['ifIndex'] . ') '; - if ($port_stats[$port['ifIndex']] && $port['disabled'] != '1') { + echo 'Port ' . $port['ifName'] . ': ' . $port['ifDescr'] . '(' . $ifIndex . ') '; + if ($port_stats[$ifIndex] && $port['disabled'] != '1') { // Check to make sure Port data is cached. - $this_port = &$port_stats[$port['ifIndex']]; + $this_port = &$port_stats[$ifIndex]; if ($device['os'] == 'vmware' && preg_match('/Device ([a-z0-9]+) at .*/', $this_port['ifDescr'], $matches)) { $this_port['ifDescr'] = $matches[1];