[rrd-users] Calculating Totals

Jean-Yves Avenard jyavenard at gmail.com
Sat Feb 13 13:01:33 CET 2010

On 13 February 2010 05:19, Shem Valentine <rrdtool at valentinenews.net>  wrote:
> I am trying to gather total bytes transferred and am having some
> inconsistencies.

> When I try to total using fetch, I get different (lower) results, which I'm
> assuming is related to UNKOWN's, am I missing something?

Your python script assumes UNKNOWN = 0 ; if you want to ignore UNKNOWN
as if they weren't there, what you should do instead is calculating
the average over the period and multiply by the sample length.
something like
   data = rrdtool.fetch("file.rrd", "-r", "604800", "--end", "now",
"--start", "e-7d", "AVERAGE")
   array = data[2]
   solar = round(array[0][1] * 86400,2)

If you want to retrieve the same data as what's used in the graph, use
the graph command in python using PRINT instead of gprint...
data = rrdtool.graph("/dev/null", "--step", "604800", "--end", "now",
"--start", "e-7d",
"VDEF:tot=x,TOTAL", "PRINT:tot:%lf")
   solar = float(data[2][0])

This will return either the same value ; or something very close...

More information about the rrd-users mailing list