mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix port association for adsl, etherlike and poe port information.
In 2c9df26bbf22af94c354bcf445b55a56eaece81a I broke the association of ports in the DB and ports just polled via SNMP for the adsl, etherlike and poe submodules and no one noticed. This fixes this issue. Sorry. Signed-off-by: Maximilian Wilhelm <max@rfc2324.org>
This commit is contained in:
@ -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');
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
if ($port_stats[$port_id] &&
|
||||
if ($port_stats[$ifIndex] &&
|
||||
$port['ifType'] == 'ethernetCsmacd' &&
|
||||
isset($port_stats[$port_id]['dot3StatsIndex'])) {
|
||||
isset($port_stats[$ifIndex]['dot3StatsIndex'])) {
|
||||
// Check to make sure Port data is cached.
|
||||
$this_port = &$port_stats[$port_id];
|
||||
$this_port = &$port_stats[$ifIndex];
|
||||
|
||||
// TODO: remove legacy check?
|
||||
$old_rrdfile = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('etherlike-'.$port['ifIndex'].'.rrd');
|
||||
|
@ -35,11 +35,11 @@ $peth_oids = array(
|
||||
'pethMainPseConsumptionPower',
|
||||
);
|
||||
|
||||
if ($port_stats[$port_id]
|
||||
if ($port_stats[$ifIndex]
|
||||
&& $port['ifType'] == 'ethernetCsmacd'
|
||||
&& isset($port_stats[$port_id]['dot3StatsIndex'])) {
|
||||
&& isset($port_stats[$ifIndex]['dot3StatsIndex'])) {
|
||||
// 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, 'poe');
|
||||
if (!file_exists($rrdfile)) {
|
||||
|
@ -280,9 +280,15 @@ foreach ($port_stats as $ifIndex => $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];
|
||||
|
Reference in New Issue
Block a user