2009-10-21

LINUX RRDTOOL

describe database creation:
rrdtool create base.rrd -s 240 \
DS:DS-NAME:GAUGE | COUNTER | DERIVE | ABSOLUTE:HEARTBEAT:0:U \
RRA:CF:XFF:3:840
-s # step default is 300 sec
DS # DATA SOURCE
DS-NAME # variable name
RRA # ROUND ROBIN ARCHIVE - one archive in database
CF # CONSOLIDATION FUNCTION - MAX | MIN | AVERAGE | LAST
PDP # PRIMARY DATA POINT
XFF # XFILES FACTOR - factor, from 0 to 1 describe how many PDP can be   UNKNOWN before record will be write to database as UNKNOWN

example:
rrdtool create base.rrd -s 240 \
DS:input:COUNTER:600:0:U \
RRA:AVERAGE:0.5:3:840

base.rrd #database file
-s 240 #record step in database are set to 240 sec
input #data chain name
COUNTER #counter type
(COUNTER - best for increasing values as network interfaces counters, you take into account that interface network counters is roll back when achieve top value 232 or 2 64 and start from zero value
GAUGE - best for non increasing values)

example of counting data:
value of first probe = 100
value of second probe = 150
value of third probe = 180

for counter type - COUNTER
will be calculate difference 150-100=50 and 180-150=30
then depends on RRA ( AVERAGE, MAX, MIN or LAST),
values will be:
for AVERAGE=(50+30)/2=40,
for MAX=50,
for MIN=30,
for LAST=30

for counter type - GAUGE
will not be calculate difference
then depends on RRA
for AVERAGE= (100+150+180)/3=143,
for MAX=180,
for MIN=100,
for LAST=180

600 #600 sec, between each probe before probe will be marked as UNKNOWN,
0 #minimal value
U #maximal value "U" is UNKNOWN
0.5 #ratio of UNKNOWN probes 0-1, 0.5 means 50%
3 #result of CF function will be get from 3 probes but 50% from them can be UNKNOWN
840 #maximal amount of probes which can be store in database (amount of records), you can not resize database file so it must be set at startup.

let's calculate how many probes should be store in our database during week:

from previous settings we assume that value is generated from 3 probes which are collected every 240 sec
3*240=720 sec.
so final value will be store in database every 720 sec
720/60=12 min.
means that every value in our html chart will be refresh every 12 min.

3600/720=5 probes per hour
24*3600/720=120 probes per day,
7*24*3600/720=840 probes per week

other:
rrdtool dump [baza.rrd] [plik.xml] #export database to xml file
rrdtool fetch [baza.rrd] AVERAGE -s -6[min | h] #get records from last 6 min | hour.

OTHER LINKS

CSS
gs.statcounter.com
regex tester