Another need to use rrdtool arose. I want to track the ups and down of disk usage compared to CPU load, so here’s what I came up with.
iostat returns some data like this:
% iostat
tty ad0 ad1 acd0 cpu
tin tout KB/t tps MB/s KB/t tps MB/s KB/t tps MB/s us ni sy in id
0 179 0.00 0 0.00 0.00 0 0.00 0.00 0 0.00 17 0 4 1 79
A little time with the man page and I settled on this incantation:
% iostat -tda -c2 | tail -1 | awk '{ print "N:" $3 ":" $6 ":" $9 ":" $16 }'
N:0.00:0.00:0.00:79
So to create an RRD around that, I used this:
rrdtool create iostat.rrd --step 300
DS:ad0:GAUGE:300:0:1000 RRA:AVERAGE:0.5:1:1200 RRA:MIN:0.5:12:1200 RRA:MAX:0.5:12:2400
DS:ad1:GAUGE:300:0:1000 RRA:AVERAGE:0.5:1:1200 RRA:MIN:0.5:12:1200 RRA:MAX:0.5:12:2400
DS:md0:GAUGE:300:0:1000 RRA:AVERAGE:0.5:1:1200 RRA:MIN:0.5:12:1200 RRA:MAX:0.5:12:2400
DS:cpu:GAUGE:300:0:100 RRA:AVERAGE:0.5:1:1200 RRA:MIN:0.5:12:1200 RRA:MAX:0.5:12:2400
and then I created a wrapper script to both update the RRD and extract the graphs:
Since iostat returns the idle time and I wanted load, I had to insert a CDEF in the graph instructions: a gentle introduction to Reverse Polish Notation, to be sure.
And the resulting graphs are here.