create influx format in mqtt which telegraf will pick up
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 3 Aug 2017 10:16:44 +0000 (12:16 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 3 Aug 2017 10:16:49 +0000 (12:16 +0200)
mqtt-rtl_433-influx.sh [new file with mode: 0755]

diff --git a/mqtt-rtl_433-influx.sh b/mqtt-rtl_433-influx.sh
new file mode 100755 (executable)
index 0000000..de4da0d
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh -xe
+
+mosquitto_sub -t rpi2/rtl433/json \
+| sed --unbuffered -e 's/^[^,]*,//' -e 's/ : /=/g' -e 's/, /,/g' -e 's/}$//' \
+-e 's/ "/ /' -e 's/"=/=/g' -e 's/,"/,/g' \
+-e 's/^ *//' \
+-e 's/ /\\ /g' \
+-e 's/,channel="*\([^,"]*\)"*,/,channel="\1",/' \
+-e 's/,battery="*\([^,"]*\)"*,/,battery="\1",/' \
+-e 's/,id=\([^,]*\),/,id=\1 /' \
+-e 's/^/rtl_433,/' \
+-e 's/"//' \
+-e 's/"//' \
+| tee /dev/stderr \
+| tee /dev/shm/433.influx \
+| mosquitto_pub -t rpi2/rtl_433/influx -l