reformat json to influx
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 3 Aug 2017 09:51:42 +0000 (11:51 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 3 Aug 2017 09:52:03 +0000 (11:52 +0200)
rtl433-influx.sh [new file with mode: 0755]

diff --git a/rtl433-influx.sh b/rtl433-influx.sh
new file mode 100755 (executable)
index 0000000..c3db305
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh -xe
+
+rtl_433 -G -F json -U \
+| tee /dev/shm/433.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/^/rtl433,/' \
+-e 's/"//' \
+-e 's/"//' \
+| tee /dev/stderr \
+| while read line ; do
+       curl -v -s -XPOST "http://10.60.0.89:8086/write?db=test" --data-binary "$line"
+done
+