aten_pdu: Add noop mode to mqtt publish script
This commit is contained in:
parent
d4d68dc962
commit
20c91fad84
1 changed files with 11 additions and 1 deletions
|
@ -5,6 +5,12 @@ umask 077
|
||||||
|
|
||||||
community="public"
|
community="public"
|
||||||
|
|
||||||
|
if [ "${1:-}" = "-n" ]; then
|
||||||
|
_noop=true
|
||||||
|
else
|
||||||
|
_noop=false
|
||||||
|
fi
|
||||||
|
|
||||||
mqtt_send() {
|
mqtt_send() {
|
||||||
topic="$1"
|
topic="$1"
|
||||||
value="$2"
|
value="$2"
|
||||||
|
@ -48,7 +54,11 @@ do
|
||||||
for key in Current Power Voltage ; do
|
for key in Current Power Voltage ; do
|
||||||
topic="home/${location}/${device}/$(echo "$key" | tr '[:upper:]' '[:lower:]')"
|
topic="home/${location}/${device}/$(echo "$key" | tr '[:upper:]' '[:lower:]')"
|
||||||
value="$(snmp_get "$name" "ATEN-PE-CFG::outlet${key}.${port}")"
|
value="$(snmp_get "$name" "ATEN-PE-CFG::outlet${key}.${port}")"
|
||||||
|
if $_noop ; then
|
||||||
|
echo "${topic} -> ${value}"
|
||||||
|
else
|
||||||
mqtt_send "$topic" "$value"
|
mqtt_send "$topic" "$value"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue