From c820614f44ece7aca11044639f77e87816078774 Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Sun, 20 Apr 2025 14:22:39 +0000 Subject: [PATCH] aten_pdu: Get PDU location from LDAP --- roles/aten_pdu/files/aten-mqtt-publish.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/roles/aten_pdu/files/aten-mqtt-publish.sh b/roles/aten_pdu/files/aten-mqtt-publish.sh index 1d6d49a..13432a0 100644 --- a/roles/aten_pdu/files/aten-mqtt-publish.sh +++ b/roles/aten_pdu/files/aten-mqtt-publish.sh @@ -36,11 +36,22 @@ for state in /run/keepalived/*.state ; do break done -ldapsearch -Q -LLL "(&(objectClass=device)(description=Aten PE*))" cn | \ - awk '{ if ($1 == "cn:") print $2 }' | while read -r name +ldapsearch -Q -LLL "(&(objectClass=device)(description=Aten PE*))" cn l | awk ' + { + if ($1 == "cn:") { + cn = $2 + } + if ($1 == "l:") { + l = substr($0, 3) + } + if ($0 == "" && cn != "" && l != "") { + print cn l + cn = "" + l = "" + } + } + ' | while read -r name location do - location="$(snmp_get "$name" RFC1213-MIB::sysLocation.0 | \ - tr '[:upper:]' '[:lower:]' | tr ' ' '_')" snmpwalk -v 1 -c "$community" "$name" -Oq \ -m ATEN-PE-CFG ATEN-PE-CFG::outletName | while read -r port device do