About
RRDtool is a data logging and graphing system for metrics (performance data).
RRDtool refers to Round Robin Database tool. RRDtool works with Round Robin Databases (RRDs). It stores and retrieves data from them.
RRDtool originated from MRTG (Multi Router Traffic Grapher). MRTG started as a tiny little script for graphing the use of a university's connection to the Internet.
RRDtool lets you:
- create a database,
- store data in it,
- retrieve that data
- create graphs in PNG format
Management
Installation
Create an RRD database
rrdtool create test.rrd \
--start 920804400 \
DS:speed:COUNTER:600:U:U \
--step=300 \
RRA:AVERAGE:0.5:1:24 \
RRA:AVERAGE:0.5:6:10
where:
- test.rrd is the round robin database
- –start define the start date with the epoch format. 920804400 means 920804400 seconds since 1 January 1970 which is 7th of March, 1999 at noon. The time stamp value is translated into local time and it will therefore look different for different time zones.
- DS define one data source (DS) named “speed” that represents a counter.
- –steps define a read every five minutes (300s). This is the default.
- RRA define a round robin archives (s):
- one averages the data every time it is read (e.g., there's nothing to average) and keeps 24 samples (24 times 5 minutes is 2 hours).
- the other averages 6 values (half hour) and contains 10 such averages (e.g. 5 hours).
Update / Insert
Data to insert:
Time | Data |
---|---|
12:05 | 12345 |
12:10 | 12357 |
12:15 | 12363 |
Syntax:
rrdtool update test.rrd 920804700:12345
rrdtool update test.rrd 920805000:12357
rrdtool update test.rrd 920805300:12363
# or with the batch mode
rrdtool update test.rrd 920804700:12345 920805000:12357 920805300:12363
where:
- the time has been translated to the epoch format
Get
rrdtool fetch test.rrd AVERAGE --start 920804700 --end 920805300
920805000: 4.0000000000e-02
920805300: 2.0000000000e-02
920805600: nan # Not A Number It can be also NAN, U or UNKN
Graph
rrdtool graph speed.png \
--start 920804400 --end 920808000 \
DEF:myspeed=test.rrd:speed:AVERAGE \
LINE2:myspeed#FF0000
where:
- speed.png is the output file
- –start and -end are the time range
- DEF is a variable definition statement named myspeed that is equals to the RRA speed out of database test.rrd.
- LINE define a line drawn with 2 pixels high, represents the variable myspeed, colored in #FF0000 red (hexadecimal rgb-representation)
Library
Port
Rrd4j is a port of RRD in Java