fix for new influx metrics layout
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 14 Apr 2019 08:21:31 +0000 (10:21 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 14 Apr 2019 08:21:31 +0000 (10:21 +0200)
temp3.sh

index 9f38b52..bb63bf8 100755 (executable)
--- a/temp3.sh
+++ b/temp3.sh
@@ -24,18 +24,18 @@ influx_mqtt() {
 
 #      echo "# $topic [$rids] -> $file"
        cat <<__SHELL__ >> /dev/shm/curl
-curl -G 'http://10.60.0.89:8086/query' --data-urlencode "db=telegraf" --data-urlencode "epoch=s" --data-urlencode "q=SELECT \"value\" FROM \"mqtt_consumer\" WHERE time > now() - $INTERVAL AND \"topic\"='$topic' $rids" | sed -e 's/^.*"values":\[\[//' -e 's/\],\[/\n/g' -e 's/,/ /g' -e 's/]].*$//' > /dev/shm/data.$file
+curl -G 'http://10.60.0.89:8086/query' --data-urlencode "db=telegraf" --data-urlencode "epoch=s" --data-urlencode "q=SELECT \"value\" FROM \"mqtt_stat\" WHERE time > now() - $INTERVAL AND \"topic\"='$topic' " | sed -e 's/^.*"values":\[\[//' -e 's/\],\[/\n/g' -e 's/,/ /g' -e 's/]].*$//' > /dev/shm/data.$file
 __SHELL__
 }
 
 influx_rtl() {
        file=$1
        shift;
-       rids=`echo $* | sed -e 's/\([0-9][0-9]*\)/ or "rid" = '"'"'\1'"'"'/g' -e 's/^ or/ AND /'`
+       rids=`echo $* | sed -e 's/\([0-9][0-9]*\)/ or "id" = '"'"'\1'"'"'/g' -e 's/^ or/ AND /'`
 
 #      echo "# $topic [$rids] -> $file"
        cat <<__SHELL__ >> /dev/shm/curl
-curl -G 'http://10.60.0.89:8086/query' --data-urlencode "db=telegraf" --data-urlencode "epoch=s" --data-urlencode "q=SELECT \"temperature_C\",\"humidity\" FROM \"rtl_433\" WHERE time > now() - $INTERVAL $rids" | sed -e 's/^.*"values":\[\[//' -e 's/\],\[/\n/g' -e 's/,/ /g' -e 's/]].*$//' > /dev/shm/data.$file
+curl -G 'http://10.60.0.89:8086/query' --data-urlencode "db=telegraf" --data-urlencode "epoch=s" --data-urlencode "q=SELECT \"temperature_C\",\"humidity\" FROM \"mqtt_rtl_433\" WHERE time > now() - $INTERVAL and model="Prologue-TH" $rids" | sed -e 's/^.*"values":\[\[//' -e 's/\],\[/\n/g' -e 's/,/ /g' -e 's/]].*$//' > /dev/shm/data.$file
 __SHELL__
 }