« Return to the blog entry
For the Radio strength website, does it have to be any particular language?
I ask because RRDTool is a pretty cool and powerful tool to graph just about anything that can provide a number.
Its a simple matter to create the database:
#!/bin/bash
#
cd /var/www/radio
/usr/bin/rrdtool create radio_db.rrd \
--step 60 \
DS:radiostrength:GAUGE:120:0:5000 \
RRA:AVERAGE:0.5:1:1440 \
RRA:AVERAGE:0.5:10:1008 \
RRA:AVERAGE:0.5:30:1440 \
RRA:AVERAGE:0.5:180:1440 \
RRA:AVERAGE:0.5:720:1440 \
RRA:MAX:0.5:1:1440 \
RRA:MAX:0.5:10:1008 \
RRA:MAX:0.5:30:1440 \
RRA:MAX:0.5:180:1440 \
RRA:MAX:0.5:720:1440
Then Update the database (via cron every 60 seconds):
### set the paths
rrdtool="/usr/bin/rrdtool"
### change to the script directory
cd /var/www/radio/
RETURN_DATA=`curl -s -N http://127.0.0.1/radio/data.php` // this is the URL to get the signal reading
### update the database
$rrdtool update radio_db.rrd --template radiostrength N:$RETURN_DATA
Then create the graph (again via cron):
## change directory to the rrdtool script dir
## Graph for last 24 hours
/usr/bin/rrdtool graph radio_graph.png \
-w 1200 -h 600 -a PNG \
--slope-mode \
--start -86400 --end now \
--font DEFAULT:7: \
--title "Radio Strength" \
--watermark "`date`" \
--vertical-label "strength" \
--lower-limit 0 \
--x-grid MINUTE:10:HOUR:1:MINUTE:120:0:%R \
--alt-y-grid --rigid \
DEF:rstrength=radio_db.rrd:radiostrength:MAX \
LINE1:rstrength#0000FF:"strength" \
GPRINT:rstrength:LAST:"Cur\: %5.2lf" \
GPRINT:rstrength:AVERAGE:"Avg\: %5.2lf" \
GPRINT:rstrength:MAX:"Max\: %5.2lf" \
GPRINT:rstrength:MIN:"Min\: %5.2lf\t\t\t" \
Then you just need to display radio_graph.png for a graph of today's results. You can create other graphs that show week, month, year, etc.
For the Radio strength website, does it have to be any particular language?
I ask because RRDTool is a pretty cool and powerful tool to graph just about anything that can provide a number.
Its a simple matter to create the database:
#!/bin/bash
#
cd /var/www/radio
/usr/bin/rrdtool create radio_db.rrd \
--step 60 \
DS:radiostrength:GAUGE:120:0:5000 \
RRA:AVERAGE:0.5:1:1440 \
RRA:AVERAGE:0.5:10:1008 \
RRA:AVERAGE:0.5:30:1440 \
RRA:AVERAGE:0.5:180:1440 \
RRA:AVERAGE:0.5:720:1440 \
RRA:MAX:0.5:1:1440 \
RRA:MAX:0.5:10:1008 \
RRA:MAX:0.5:30:1440 \
RRA:MAX:0.5:180:1440 \
RRA:MAX:0.5:720:1440
Then Update the database (via cron every 60 seconds):
#!/bin/bash
#
### set the paths
rrdtool="/usr/bin/rrdtool"
### change to the script directory
cd /var/www/radio/
RETURN_DATA=`curl -s -N http://127.0.0.1/radio/data.php` // this is the URL to get the signal reading
### update the database
$rrdtool update radio_db.rrd --template radiostrength N:$RETURN_DATA
Then create the graph (again via cron):
#!/bin/bash
#
## change directory to the rrdtool script dir
cd /var/www/radio/
## Graph for last 24 hours
/usr/bin/rrdtool graph radio_graph.png \
-w 1200 -h 600 -a PNG \
--slope-mode \
--start -86400 --end now \
--font DEFAULT:7: \
--title "Radio Strength" \
--watermark "`date`" \
--vertical-label "strength" \
--lower-limit 0 \
--x-grid MINUTE:10:HOUR:1:MINUTE:120:0:%R \
--alt-y-grid --rigid \
DEF:rstrength=radio_db.rrd:radiostrength:MAX \
LINE1:rstrength#0000FF:"strength" \
GPRINT:rstrength:LAST:"Cur\: %5.2lf" \
GPRINT:rstrength:AVERAGE:"Avg\: %5.2lf" \
GPRINT:rstrength:MAX:"Max\: %5.2lf" \
GPRINT:rstrength:MIN:"Min\: %5.2lf\t\t\t" \
Then you just need to display radio_graph.png for a graph of today's results. You can create other graphs that show week, month, year, etc.