Fix EdgeCore ifOperStatus does not follow the Cisco convention

* Since EdgeCore use "lowerLayerDown" in ifOperStatus when port is unplugged
* On the other way, Cisco use briefly "down".
* So change "lowerLayerDown" to "down" to workaround the bug that will make port always show as up/up
This commit is contained in:
Ming-Han Yang
2019-08-17 22:26:09 +08:00
parent e398c43a1a
commit 27971b34a8
2 changed files with 37 additions and 0 deletions

View File

@@ -320,6 +320,10 @@ if ($device['os'] == 'junos') {
require_once 'ports/junos-vcp.inc.php'; require_once 'ports/junos-vcp.inc.php';
} }
if ($device['os'] == 'edgecos') {
require_once 'ports/edgecos.inc.php';
}
if (Config::get('enable_ports_adsl')) { if (Config::get('enable_ports_adsl')) {
$device['xdsl_count'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `device_id` = ? AND `ifType` in ('adsl','vdsl')", [$device['device_id']]); $device['xdsl_count'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `device_id` = ? AND `ifType` in ('adsl','vdsl')", [$device['device_id']]);
} }

View File

@@ -0,0 +1,33 @@
<?php
/**
* edgecos.inc.php
*
* LibreNMS Edgecos Ports fix
*
* Fix the problem that EdgeCore did not follow the ifOperStatus convention
*
* 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 2019 Ming-Han Yang
* @author Ming-Han Yang <soto2080edu@g.ncu.edu.tw>
*/
foreach ($port_stats as & $port) {
if ($port['ifOperStatus'] == 'lowerLayerDown') {
$port['ifOperStatus'] = 'down';
}
}
unset($port);
d_echo($port_stats);