RRDtool is a time-series database with graphing capabilities. With every data update, it stores a timestamp (seconds since the unix epoch).
“RRD” stands for Round Robin Database. We establish the size of the database at the time we create it. It never grows beyond that size, simply overwriting old data in a round-robin fashion.
RRD can store absolute value or the change from the previous value.
RRD needs values a pre-defined intervals. Otherwise, it fills missing values with UNKNOWN.
# apt-get install rrdtool
Creating an RRD database:
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
start
is the number of seconds since the epoch, and must be in the future.
step
is the update interval for the database in seconds (here, every five minutes).
DS
is the “data source” keyword, like:
"DS:variable_name:DST:heartbeat:min:max"
…where “variable_name” is the name under which RRDtool saves the value in the database. DST (“data source type”) can be COUNTER, DERIVE, ABSOLUTE, or GAUGE. COUNTER saves the rate of change of the value over a step period (assumes the value always increases, like packet counters on a router). DERIVE is the same as COUNTER, but it allows negative values as well. ABSOLUTE saves the rate of change, but assumes a previous value of 0. GAUGE saves the actual value rather than the rate of change.
“heartbeat” is the total number of seconds (including the step
value) RDDtool waits before recording an UNKNOWN value for the interval.
RRDtool records any value falling outside the “min:max” range as UNKNOWN.
A database can hold many DS
fields.
RRA
declares a Round Robin Archive, like:
RRA:CF:xff:step:rows
An RRA line sets the number Consolidated Data Points we store in the database (and, by implication, the size/scope of the database).
CF
is “consolidation function”, which can be AVERAGE, MINIMUM, MAXIMUM, and LAST.
A CDP is CF’d from step number of Primary Data Points.
rows
is the number of CDP values held in the database (before it rolls over).
In our database creation example above, the first RRA AVERAGEs 12 PDP’s to form one CDP. This database archives 24 (rows) of CDP’s. Each PDP occurs at 300 seconds. 12 PDP’s represent 12 times 300 seconds, which is 1 hour. So, one CDP represents data worth 1 hour. 24 such CDP’s represent 1 day (1 hour times 24 CDPs). In total, this RRA archives one day. After 24 CDP’s, CDP number 25 replaces the first CDP.
The second RRA saves 31 CDP’s (each CPD represents an AVERAGE value for a day — 288 PDPs, each covering 300 seconds, equals 24 hours), archiving one month in total.
A single database can have many RRA’s. With multiple DS’s, each individual RRA saves data for all the DS’s in the database.