From 190a377076613e947c83640a5413c76e7c5eda92 Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Sat, 19 Apr 2025 20:05:48 +0000 Subject: [PATCH] aten_pdu: Try to get full hosntname for mqtt pub --- roles/aten_pdu/files/aten-mqtt-publish.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/roles/aten_pdu/files/aten-mqtt-publish.sh b/roles/aten_pdu/files/aten-mqtt-publish.sh index 7dcfcaa..1d6d49a 100644 --- a/roles/aten_pdu/files/aten-mqtt-publish.sh +++ b/roles/aten_pdu/files/aten-mqtt-publish.sh @@ -51,7 +51,24 @@ do continue ;; esac - for key in Current Power Voltage ; do + if device_name="$(ldapsearch -Q -LLL cn="${device}.*" cn | awk " + { + if (\$1 == \"cn:\") { + if (name) { + exit 1 + } + name=\$2 + } + } END { + if (!name) { + exit 1 + } + print name + } + ")" ; then + device="$device_name" + fi + for key in Current Power Voltage ; do topic="home/${location}/${device}/$(echo "$key" | tr '[:upper:]' '[:lower:]')" value="$(snmp_get "$name" "ATEN-PE-CFG::outlet${key}.${port}")" if $_noop ; then