[#808] LLDP topology fetch (phase 2): 18 links from LibreNMS discovery
ci / audit (push) Successful in 43s

lldp-topology.sh pulls the links table (hostnames + ports both ends) —
input for GLPI NetworkEquipment + port-connection population under the
Change being filed for phase 2a.
https://projects.knownelement.com/issues/808
This commit is contained in:
2026-09-06 00:11:25 -05:00
parent efba482c52
commit 4c464fa6a9
3 changed files with 45 additions and 1 deletions
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# lldp-topology.sh — pull LLDP neighbor links from LibreNMS [#808 phase 2]
#
# Reads the LibreNMS links table (LLDP/CDP discovery) and emits
# hostnameA, portA, hostnameB, portB rows. Run ON tsys-librenms as root
# (MariaDB local auth) or via: lldp-topology.sh --fetch
#
# Output feeds GLPI NetworkEquipment + port-connection creation
# (phase 2 of the GLPI x LibreNMS cross-feed). See librenms-glpi-drift.sh
# for the device-level report (phase 1).
set -uo pipefail
LNMS_HOST="${LNMS_HOST:-100.86.204.77}"
QUERY="SELECT d1.hostname, p1.ifName, d2.hostname, p2.ifName
FROM links l
JOIN devices d1 ON l.local_device_id=d1.device_id
JOIN devices d2 ON l.remote_device_id=d2.device_id
LEFT JOIN ports p1 ON l.local_port_id=p1.port_id
LEFT JOIN ports p2 ON l.remote_port_id=p2.port_id;"
if [ "${1:-}" = "--fetch" ]; then
ssh -o BatchMode=yes "root@${LNMS_HOST}" "mysql -N librenms -e \"$QUERY\"" 2>/dev/null
else
# local mode: run on tsys-librenms itself
mysql -N librenms -e "$QUERY" 2>/dev/null
fi