Table of Contents
Tom's RRD Notes
This is an informal collection of notes to help me understand an RRD database.
Definition
An RRD database is a circular database whose size is predetermined at creation. The RRD database tool has a set of commands to add new data, fetch data and graph data from the database. The data base expects a time series sequence of data. Each value is saved with a time stamp.
Creation
The RRD database is created with the following syntax:
rrdtool create target.rrd \ --start 1023654125 \ --step 300 \ DS:mem:GAUGE:600:0:671744 \ RRA:AVERAGE:0.5:12:24 \ RRA:AVERAGE:0.5:288:31
In this example, target.rrd is the name of the database.
The start time in epoch seconds is given by –start 1023654125
The step is the time frequency in seconds. –step 300
DS is a keyword meaning DataSource followed by the variable name, in this case “mem”.
GAUGE is the type of data which can be COUNTER, DERIVE, ABSOLUTE, GAUGE.Use GAUGE to store the data itself.
Next is the heartbeat, set to 600 here. If the database doesn't get an update every 300 seconds, in the next 300 second update it will store an UNKNOWN for the missed reading. Heartbeat then is is the number of seconds before data becomes *unknown*
The next two parms are minimum and maximum values if known. Any values outside these two parms are set to unknown. The min and max shown here are 0 and 671744.
The next line declares a round robin archive (RRA). The syntax for declaring an RRA is:
RRA:CF:xff:step:rows
RRA is the keyword to declare RRAs. The consolidation function (CF) can be AVERAGE, MINIMUM, MAXIMUM, and LAST.
Because our step size is 300, or every 5 minutes, 12 of the data points would make one hour and one days worth of archive would be 24 hours. In other words, 12 of the readings would be averaged making up one hours worth of averaged data and 24 one hour averages would be archived. This is represented by the two parameters 12:24
The next RRA stores 31 days (one month) worth of data using 288 which is the number of readings averaged for one day (12 readings per hour times 24 hours = 288), so we have the two parameters 288:31.
Operationally
Running a program at regular intervals is OS specific. But here is an example in pseudo code:
- Get the value and put it in variable “$speed”
- rrdtool update speed.rrd N:$speed
(N is an RRD keyword for system time)
Run the above script every five minutes.
After running the script, create the graph and view it in an html page, index.html, which contains the graph in speed.png.
Contents of index.html:
<HTML><HEAD><TITLE>Speed</TITLE></HEAD><BODY>\\ <IMG src="speed.png" alt="Speed in meters per second">\\ </BODY></HTML>\\