diff --git a/roles/aten_pdu/files/aten-mqtt-publish.sh b/roles/aten_pdu/files/aten-mqtt-publish.sh index 5b486c6..7dcfcaa 100644 --- a/roles/aten_pdu/files/aten-mqtt-publish.sh +++ b/roles/aten_pdu/files/aten-mqtt-publish.sh @@ -5,6 +5,12 @@ umask 077 community="public" +if [ "${1:-}" = "-n" ]; then + _noop=true +else + _noop=false +fi + mqtt_send() { topic="$1" value="$2" @@ -48,7 +54,11 @@ do 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}")" - mqtt_send "$topic" "$value" + if $_noop ; then + echo "${topic} -> ${value}" + else + mqtt_send "$topic" "$value" + fi done done done