====== Plotta temperaturer från Webswitch ====== ===== Hämta data från webswitch ===== The script below collect the temperature data from the webswitch and saves it in a file. After that the data is plotted with the gnuplot scripts. The script is named temp_webswitch in the example below. #!/bin/bash # # Small script to read and plot temperature # # 1)Save timestamp # 2)Retrieve Outdoor temperature # 3)Retrieve Indoor Temperature # 4)Save time, outdoortemp, indoor temp to file tempdata # 5)plot three figures # DATE=$(date +"%s" ) UTE=$(curl -s "http://xxxxxx.shacknet.nu:xxxx/temp.egi" | perl -e 'foreach (<>){if(/Current Temp B/){($x)=/Current Temp B.+TD> (.+) C){if(/Current Temp A/){($x)=/Current Temp A.+TD> (.+) C> /home/sm3sgp/temp/tempdata /usr/bin/gnuplot "/home/xxxxx/temp/plot.gnu" /usr/bin/gnuplot "/home/xxxxx/temp/plot24.gnu" /usr/bin/gnuplot "/home/xxxxx/temp/plotweek.gnu" ===== Plot the figures ===== The scripts plot.gnu, plot24.gnu and plotweek.gnu can be modified to plot a specific time period per figure. It generates a small .png file. # # Plot the number of lines specified in the tail command below. # set terminal png set output "/home/xxxxx/temp/tempweek.png" set grid set ytics 5 set xdata time set timefmt "%s" set format x "%R" set yrange [-10:35] plot "< tail -550 /home/xxxxx/temp/tempdata" using 1:2 with lines title "Temperatur utomhus", "< tail -550 /home/xxxxx/temp/tempdata" using 1:3 with lines title "Temperatur inomhus" ===== Run a crontab job ===== Edit the crontab file with command: crontab -e # m h dom mon dow command 1-59/2 * * * * /home/xxxxx/temp/temp_webswitch &> /dev/null