added s_all to display count (and bettery) for all sensors
[eg5120] / mqtt-pgsql.sh
1 #!/bin/sh -e
2
3 mosquitto_sub -h localhost -t eg5120 | while read json ; do
4         date=$( date +%Y-%m-%dT%H:%M:%S )
5         echo -n $date ' '
6         echo $json | tee data/$date.json | tee /dev/shm/last-eg5120.json
7         psql --quiet -c "copy eg5120 (json) from '/dev/shm/last-eg5120.json'" eg5120
8 done