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