[#808] LLDP topology fetch (phase 2): 18 links from LibreNMS discovery
ci / audit (push) Successful in 43s
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:
@@ -1 +1 @@
|
|||||||
#705
|
#808
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
pfv-r5-core-01.knel.net g26 ap-tablemount.knel.net eth0
|
||||||
|
pfv-r3-tor-stor-01.knel.net g20 pfv-r5-core-01.knel.net g13
|
||||||
|
pfv-r3-tor-stor-01.knel.net g21 pfv-r5-core-01.knel.net g16
|
||||||
|
pfv-r3-tor-stor-01.knel.net g22 pfv-r5-core-01.knel.net g15
|
||||||
|
pfv-r3-tor-stor-01.knel.net g23 pfv-r5-core-01.knel.net g14
|
||||||
|
pfv-r3-tor-stor-01.knel.net g24 pfv-r5-core-01.knel.net g17
|
||||||
|
pfv-r3-tor-mgmt-01.knel.net g24 pfv-r5-core-01.knel.net g12
|
||||||
|
pfv-r6-mgmt-01.knel.net g1 pfv-r5-core-01.knel.net g39
|
||||||
|
pfv-r5-core-01.knel.net g12 pfv-r3-tor-mgmt-01.knel.net g24
|
||||||
|
pfv-r5-core-01.knel.net g13 pfv-r3-tor-stor-01.knel.net g20
|
||||||
|
pfv-r5-core-01.knel.net g14 pfv-r3-tor-stor-01.knel.net g23
|
||||||
|
pfv-r5-core-01.knel.net g15 pfv-r3-tor-stor-01.knel.net g22
|
||||||
|
pfv-r5-core-01.knel.net g16 pfv-r3-tor-stor-01.knel.net g21
|
||||||
|
pfv-r5-core-01.knel.net g17 pfv-r3-tor-stor-01.knel.net g24
|
||||||
|
pfv-r5-core-01.knel.net g39 pfv-r6-mgmt-01.knel.net g1
|
||||||
|
pfv-r5-core-01.knel.net g9 ap-wallmount.knel.net eth0
|
||||||
|
pfv-r5-core-01.knel.net g41 pfv-tsys1.knel.net nic0
|
||||||
|
pfv-r5-core-01.knel.net g40 pfv-tsys1.knel.net nic1
|
||||||
|
Executable
+26
@@ -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
|
||||||
Reference in New Issue
Block a user