From 27971b34a86c4a347d576a6add0583a60aeed912 Mon Sep 17 00:00:00 2001 From: Ming-Han Yang Date: Sat, 17 Aug 2019 22:26:09 +0800 Subject: [PATCH] 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 --- includes/polling/ports.inc.php | 4 ++++ includes/polling/ports/edgecos.inc.php | 33 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 includes/polling/ports/edgecos.inc.php diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 45e48ba3a6..e661b1955d 100644 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -320,6 +320,10 @@ if ($device['os'] == 'junos') { require_once 'ports/junos-vcp.inc.php'; } +if ($device['os'] == 'edgecos') { + require_once 'ports/edgecos.inc.php'; +} + 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']]); } diff --git a/includes/polling/ports/edgecos.inc.php b/includes/polling/ports/edgecos.inc.php new file mode 100644 index 0000000000..863120725c --- /dev/null +++ b/includes/polling/ports/edgecos.inc.php @@ -0,0 +1,33 @@ +. +* +* @package LibreNMS +* @link http://librenms.org +* @copyright 2019 Ming-Han Yang +* @author Ming-Han Yang +*/ +foreach ($port_stats as & $port) { + if ($port['ifOperStatus'] == 'lowerLayerDown') { + $port['ifOperStatus'] = 'down'; + } +} +unset($port); +d_echo($port_stats);