X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=temp2.sh;h=5b93cfc5b4c91789c633a1aeea28ae6d6ed69c03;hb=291365eb1b01e9a359f791990cbca3cbbb03cc18;hp=3ffd76db8c248cd43478881337a964a778c21a77;hpb=8706ce2f99dfd5dc9dacd869ce596e35e577777b;p=vaillant-thermostat diff --git a/temp2.sh b/temp2.sh index 3ffd76d..5b93cfc 100755 --- a/temp2.sh +++ b/temp2.sh @@ -1,4 +1,4 @@ -#!/bin/sh -x +#!/bin/sh # sudo apt-get install jq # ln -s `pwd`/temp2.sh /var/www/html/temp2.sh @@ -12,6 +12,10 @@ INTERVAL=`echo $QUERY_STRING | grep -i 't=[0-9]*h' | sed 's/.*t=\([0-9]*h\).*/\1/'` test -z "$INTERVAL" && INTERVAL=48h +LINES=0 +echo $QUERY_STRING | grep -i 'lines=' >/dev/null && LINES=1 + + 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\"='stat/boiler/DS18B20/temperature'" | sed -e 's/^.*"values":\[\[//' -e 's/\],\[/\n/g' -e 's/,/ /g' -e 's/]].*$//' > /dev/shm/DS18B20-temperature 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\"='stat/boiler/DHT22/temperature'" | sed -e 's/^.*"values":\[\[//' -e 's/\],\[/\n/g' -e 's/,/ /g' -e 's/]].*$//' > /dev/shm/DHT22-temperature 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\"='stat/boiler/DHT22/humidity'" | sed -e 's/^.*"values":\[\[//' -e 's/\],\[/\n/g' -e 's/,/ /g' -e 's/]].*$//' > /dev/shm/DHT22-humidity @@ -33,7 +37,7 @@ curl -G 'http://10.60.0.89:8086/query' --data-urlencode "db=telegraf" --data-url cd /home/pi/vaillant-thermostat/ -gnuplot -e "t_mean=`head -1 /dev/shm/temperature.mean.spread`;t_spread=`tail -1 /dev/shm/temperature.mean.spread`;h_mean=`head -1 /dev/shm/humidity.mean.spread` ; h_spread=`tail -1 /dev/shm/humidity.mean.spread`" temp2.gnuplot +gnuplot -e "t_mean=`head -1 /dev/shm/temperature.mean.spread`;t_spread=`tail -1 /dev/shm/temperature.mean.spread`;h_mean=`head -1 /dev/shm/humidity.mean.spread` ; h_spread=`tail -1 /dev/shm/humidity.mean.spread` ; lines=$LINES" temp2.gnuplot GRAY=`echo $QUERY_STRING | grep -i gray` if [ ! -z "$GRAY" ] ; then @@ -43,6 +47,23 @@ fi set > /dev/shm/temp2.cgi.vars +if echo $HTTP_USER_AGENT | grep Mozilla > /dev/null ; then + echo "Content-type: text/html\r\n\r\n" + cat << __HTML__ + +
+ + + + + +
+ + +__HTML__ + exit 0 +fi + echo "Location: $REQUEST_SCHEME://$SERVER_NAME:$SERVER_PORT/temp2$GRAY.png" echo