[rrd-users] Getting monthly average from an rrd file

Steve Shipway s.shipway at auckland.ac.nz
Thu Jul 31 01:08:41 CEST 2008


> I would like to get the monthly average of something returned from
> rrdtool, but I cannot seem to do it.  When I try it, it returns daily
> averages.  I read in the docs the resolution has to be divisible by the
> start and end times.  How does rrdtool calculate the averages for the
> graphs it displays?

RRD returns data from the RRA which most closely matches the user's request.

If you don't have a one-bucket-per-month RRA, then when you ask for a monthly average, it will give you the set of data most closely matching - with a standard MRTG-generated set, this is the Yearly RRA, which has one bucket per day.  Hence you retrieve a set of 30 (or 31, or 28...) values.

It should be simple enough to make your code calculate an average of the values returned by your RRD fetch request?  This is how Routers2 manages the monthly Total or Average calculations outside of the graph.

Alternatively, add a 1-bucket-per-month AVERAGE RRA to your RRD file.  This might be difficult, though, as months do not have regular sizes - another reason to stick with making the extra calculation youself.

Interestingly, you get the same problem in reverse when trying to calculate 95th percentile (forgetting for the moment that RRD 1.3 can now do this itself via a specially-crafted RRA).  In this case, you want the smallest granularity to minimise errors, but for a 'yearly' 95th percentile, the best available is the 1-per-day RRA.

HTH, E&OE...

Steve



More information about the rrd-users mailing list