[rrd-users] Rrdtool for counting irregular events

Simon Hobson linux at thehobsons.co.uk
Sun May 20 17:44:32 CEST 2012

Rafal Gwizdala wrote:
>Whoa, not so fast. TOTAL is available for VDEF only so I can 
>calculate the total for the whole graph only. Still don't see a way 
>to do the same for each aggregation step shown on the graph.

If your step period for the graph is (say) 1800s, then do :
where a is your stored rate, and then plot x.

>If there was some variable representing graph's time resolution I 
>could use it for calculating sums the way you described

There is, but you need to work it out before you call the graph. When 
I do graphs, I work out what resolution I'm going to plot and work 
from there. So I tend to do something like :
case period in
     step=300; time=86400 ;;
     step=1800; time=604800 ;;

Then I work out start and end times :
  e=`date +%s`
  end=$(( ${e} / ${step} * ${step} ))
  start=$(( ${end} - ${time} ))

So in Bash, $end is now the exact time at the end of the last 
complete period, and $start is that time less the length of the graph.

I can now use "--start ${start} --end ${end}" in the graph 
definition, and of course, you can also use $step in calculations :
for example.

Simon Hobson

Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.

More information about the rrd-users mailing list