From a9befd3b9886ef5178f99471a5cf6a183ff7f7e5 Mon Sep 17 00:00:00 2001 From: Peca Nesovanovic <59750439+Npeca75@users.noreply.github.com> Date: Wed, 21 Feb 2024 19:29:43 +0100 Subject: [PATCH] fix tp-link jetstream FDB discovery (#14321) * jetstream fdb discovery * ci --- .../discovery/fdb-table/jetstream.inc.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 includes/discovery/fdb-table/jetstream.inc.php diff --git a/includes/discovery/fdb-table/jetstream.inc.php b/includes/discovery/fdb-table/jetstream.inc.php new file mode 100644 index 0000000000..a21376450e --- /dev/null +++ b/includes/discovery/fdb-table/jetstream.inc.php @@ -0,0 +1,46 @@ +. + * + * @link https://www.librenms.org + * + * @copyright 2022 Peca Nesovanovic + * @author Peca Nesovanovic + */ +$oids = SnmpQuery::allowUnordered()->hideMib()->walk('Q-BRIDGE-MIB::dot1qTpFdbPort')->table(2); +if (! empty($oids)) { + $insert = []; + d_echo('Jetstream: FDB Table'); + foreach ($oids as $vlan => $oidData) { + foreach ($oidData as $mac => $macData) { + $port = $macData['dot1qTpFdbPort']; + //try both variation with & without space + $port_id = find_port_id('gigabitEthernet 1/0/' . $port, 'gigabitEthernet1/0/' . $port, $device['device_id']) ?? 0; + $mac_address = implode(array_map('zeropad', explode(':', $mac))); + if (strlen($mac_address) != 12) { + d_echo("MAC address padding failed for $mac\n"); + continue; + } + $vlan_id = $vlans_dict[$vlan] ?? 0; + $insert[$vlan_id][$mac_address]['port_id'] = $port_id; + d_echo("vlan $vlan_id mac $mac_address port $port_id\n"); + } + } +} + +echo PHP_EOL;