Monday 1 February 2010

Configuring RRDtool to display 1-wire results

I can't claim much credit for the scripting I used to generate graphs as it's all based on this excellent guide on owfs's site: owfs Gardening

Here's something I learned though...
Run the script provided to make the database, but notice the following: The script provided uses '--step 300' and 'AVERAGE' settings. These two items are critical to understand, otherwise like me, you'll be wondering why the rrdtool graphs don't update if you run the data collection script very frequently (for example, every minute).

rrdtool create temperature.rrd --step 300 \
DS:temp:GAUGE:600:-273:5000 \
RRA:AVERAGE:0.5:1:1200 \
RRA:MIN:0.5:12:2400 \
RRA:MAX:0.5:12:2400 \
RRA:AVERAGE:0.5:12:2400
The sample rrdtool create statement from rrdcreate's man.

To explain this as best I can, rrdtool is fed with a batch of results retrieved from the temperature sensors at 1 minute intervals (assuming you setup cron to do so). As the step is set for 300 seconds, it doesn't populate it's main table with these results until 300 seconds after the last update, instead it retains them in an 'archive'. Then on the 300 second mark, it averages the results and publishes them.
So, if you took 5 readings in that 300 second period, lets say of 5, 10, 15, 20, 15, you won't see this displayed in the graph, instead it will be replaced by the average of 13.

This is well explained in the rrdcreate man.

This leads into a separate question... considering I created the initial database using a step of 300, how can I modify this to a shorter step retrospectively? Well you can do it, but just be aware that it doesn't maintain data integrity.
As the values published to the database are 'points in time' of 300 seconds each, modifying the step will cause the data points to assume this new time-scale. In my case, I ran the command 'rrdtool dump temperature.rrd >> database.xml' to output the database into an XML file. I then modified the step values in the second line of the database from 300 to 120 seconds. I then backed-up my old database and exported or 'rrdrestor'ed the data into a new database with the command 'rrdrestore database.xml temperature.rrd'.

On generating graphs with the new database I noticed that the shorter step of 120 seconds caused the newly graphed data-set to compact, effectively making each of the individual records into 120 second events, rather than the 300 second ones which they really were.

Hence, I believe it's true to say that there is no method of retrospectively adjusting the step of an rrdtool database as it affects the 'point in time' nature of the events contained within it.

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete