mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix incorrect eth0 status for Ubiquiti AirFiber 5XHD (#12025)
* UBNT AF LTU: Fix incorrect eth0 status during discovery * UBNT AF LTU: Update test data * UBNT AF LTU: Remove eth0 if afLTUethConnected is not set * UBNT AF LTU: Use require instead of require_once
This commit is contained in:
@@ -10,6 +10,11 @@ $port_stats = snmpwalk_cache_oid($device, 'ifAlias', $port_stats, 'IF-MIB');
|
||||
$port_stats = snmpwalk_cache_oid($device, 'ifType', $port_stats, 'IF-MIB');
|
||||
$port_stats = snmpwalk_cache_oid($device, 'ifOperStatus', $port_stats, 'IF-MIB');
|
||||
|
||||
// Get correct eth0 port status for AirFiber 5XHD devices
|
||||
if ($device['os'] == 'airos-af-ltu') {
|
||||
require 'ports/airos-af-ltu.inc.php';
|
||||
}
|
||||
|
||||
// End Building SNMP Cache Array
|
||||
d_echo($port_stats);
|
||||
|
||||
|
46
includes/discovery/ports/airos-af-ltu.inc.php
Normal file
46
includes/discovery/ports/airos-af-ltu.inc.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* airos-af-ltu.inc.php
|
||||
*
|
||||
* LibreNMS eth0 port discovery module for Ubiquiti airFiber 5XHD
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2020 Denny Friebe
|
||||
* @author Denny Friebe <denny.friebe@icera-network.de>
|
||||
*/
|
||||
|
||||
$airos_eth_stat = snmpwalk_cache_oid($device, 'afLTUethConnected', array(), 'UBNT-AFLTU-MIB', null, '-OteQUsb');
|
||||
|
||||
foreach ($port_stats as $index => $afport_stats) {
|
||||
if ($afport_stats['ifDescr'] == 'eth0') {
|
||||
if (isset($airos_eth_stat[0]['afLTUethConnected'])) {
|
||||
$port_stats[$index]['ifOperStatus'] = ($airos_eth_stat[0]['afLTUethConnected'] == 1 ? "up" : "down");
|
||||
} else {
|
||||
/**
|
||||
* Ubiquiti uses separate OIDs for ethernet status. Sometimes the devices have difficulties to return
|
||||
* a value for the OID "afLTUethConnected".
|
||||
* Because "IF-MIB" reads wrong information we remove the existing entry for "eth0" if "afLTUethConnected"
|
||||
* could not be read to prevent wrong information from being stored.
|
||||
*/
|
||||
|
||||
unset($port_stats[$index]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
unset($airos_eth_stat);
|
@@ -25,18 +25,26 @@
|
||||
|
||||
$airos_stats = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.41112.1.10.1.6', array(), 'UBNT-AFLTU-MIB');
|
||||
|
||||
if (isset($airos_stats[0]['afLTUethConnected'])) {
|
||||
foreach ($port_stats as $index => $afport_stats) {
|
||||
if ($afport_stats['ifDescr'] == 'eth0') {
|
||||
foreach ($port_stats as $index => $afport_stats) {
|
||||
if ($afport_stats['ifDescr'] == 'eth0') {
|
||||
if (isset($airos_stats[0]['afLTUethConnected'])) {
|
||||
$port_stats[$index]['ifOperStatus'] = ($airos_stats[0]['afLTUethConnected'] == "connected" ? "up" : "down");
|
||||
$port_stats[$index]['ifHCInOctets'] = $airos_stats[0]['afLTUethRxBytes'];
|
||||
$port_stats[$index]['ifHCOutOctets'] = $airos_stats[0]['afLTUethTxBytes'];
|
||||
$port_stats[$index]['ifHCInUcastPkts'] = $airos_stats[0]['afLTUethRxPps'];
|
||||
$port_stats[$index]['ifHCOutUcastPkts'] = $airos_stats[0]['afLTUethTxPps'];
|
||||
$port_stats[$index]['ifHighSpeed'] = '1000';
|
||||
} else {
|
||||
/**
|
||||
* Ubiquiti uses separate OIDs for ethernet status. Sometimes the devices have difficulties to return
|
||||
* a value for the OID "afLTUethConnected".
|
||||
* Because "IF-MIB" reads wrong information we remove the existing entry for "eth0" if "afLTUethConnected"
|
||||
* could not be read to prevent wrong information from being stored.
|
||||
*/
|
||||
|
||||
break;
|
||||
unset($port_stats[$index]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -163,7 +163,7 @@
|
||||
"ifPromiscuousMode": null,
|
||||
"ifHighSpeed": null,
|
||||
"ifHighSpeed_prev": null,
|
||||
"ifOperStatus": "down",
|
||||
"ifOperStatus": "up",
|
||||
"ifOperStatus_prev": null,
|
||||
"ifAdminStatus": null,
|
||||
"ifAdminStatus_prev": null,
|
||||
@@ -1131,7 +1131,7 @@
|
||||
"ifHighSpeed": 1000,
|
||||
"ifHighSpeed_prev": null,
|
||||
"ifOperStatus": "up",
|
||||
"ifOperStatus_prev": "down",
|
||||
"ifOperStatus_prev": "up",
|
||||
"ifAdminStatus": "up",
|
||||
"ifAdminStatus_prev": null,
|
||||
"ifDuplex": null,
|
||||
|
@@ -163,7 +163,7 @@
|
||||
"ifPromiscuousMode": null,
|
||||
"ifHighSpeed": null,
|
||||
"ifHighSpeed_prev": null,
|
||||
"ifOperStatus": "down",
|
||||
"ifOperStatus": "up",
|
||||
"ifOperStatus_prev": null,
|
||||
"ifAdminStatus": null,
|
||||
"ifAdminStatus_prev": null,
|
||||
@@ -917,7 +917,7 @@
|
||||
"ifHighSpeed": 1000,
|
||||
"ifHighSpeed_prev": null,
|
||||
"ifOperStatus": "up",
|
||||
"ifOperStatus_prev": "down",
|
||||
"ifOperStatus_prev": "up",
|
||||
"ifAdminStatus": "up",
|
||||
"ifAdminStatus_prev": null,
|
||||
"ifDuplex": null,
|
||||
|
Reference in New Issue
Block a user