- jones@home:~$ cat rrdtemperature/rrdupdate.sh
- #!/bin/sh
- ##rrdtool create temperature.rrd --start n --step 300 DS:in1:GAUGE:500:40:110 DS:out:GAUGE:500:20:110 DS:in2:GAUGE:500:40:110 RRA:MIN:0.5:288:1440 RRA:LAST:0.5:1:14400 RRA:AVERAGE:0.5:5:14400
- #get temperature
- head -n 1 /dev/ttyUSB0 >/dev/null 2>&1
- temp=`head -n 1 /dev/ttyUSB0`
- in1=`echo "$temp" | cut -d "^" -f 1-1 | python -c "print round(float(raw_input()), 1)"`
- out=`echo "$temp" | cut -d "^" -f 2-2 | python -c "print round(float(raw_input()), 1)"`
- in2=`echo "$temp" | cut -d "^" -f 3-3 | python -c "print round(float(raw_input()), 1)"`
- #update rrdtool
- rrdtool update /home/jones/rrdtemperature/temperature.rrd N:$in1:$out:$in2
- #update webpage
- rrdtool graph /var/www/temperature/temp.png -F -E --legend-position=south --alt-autoscale --height=700 --width=1000 --color=BACK#FFFFFF --start end-2d --vertical-label "°F" --border 0 --font DEFAULT:11:sans-serif --disable-rrdtool-tag DEF:in1=/home/jones/rrdtemperature/temperature.rrd:in1:AVERAGE LINE1:in1#ff0000 DEF:out=/home/jones/rrdtemperature/temperature.rrd:out:AVERAGE LINE1:out#008000 DEF:in2=/home/jones/rrdtemperature/temperature.rrd:in2:AVERAGE LINE1:in2#4169E1
- cp /home/jones/rrdtemperature/index /var/www/temperature/index.html
- #sed -i "/hour/ s,SIXTYFOUR,$graph," /var/www/temperature/index.html
- sed -i "/in1/ s/INTERIOR/$in1/" /var/www/temperature/index.html
- sed -i "/out/ s/EXTERIOR/$out/" /var/www/temperature/index.html
- sed -i "/in2/ s/ROOM/$in2/" /var/www/temperature/index.html
temperature script
Posted by Anonymous on Sat 23rd Nov 2013 10:02
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
kpaste.net RSS