# [rrd-users] [unsure] Re: Things not adding up

Alex van den Bogaerdt alex at vandenbogaerdt.nl
Tue Apr 5 22:03:08 CEST 2011

```> In this case I don't think your argument is relevant.  I'm only storing
> in/out bits for a single device in each rrd file... so I wouldn't store a
> sum across devices in any one rrd. The problem appears when I read all
> these separate files for the aggregate graph. Also.. if you manually add
> up the displayed average and current values they do agree with the printed
> totals.. only the max values are coming out wrong. Also.. it's off by a
> rather odd amount.

max(A)+max(B) does not equal max(A+B)

Simon tried to explain. I think another example may be helping.

Suppose device "A" is doing 9,8,7,6,5,4,3,2,1
and device "B" is doing 1,2,3,4,5,6,7,8,9

Your graph will show a staircase going down from 9 to 1, the X-axis, and a
Your GPRINT will show max(A)=9, max(B)=9, total=10. You would be asking why
it's 10, not 18.

max(A) is 9, max(B) is 9. You are summing max(A)+max(B) and get 18.
However, when you stack A and B, you'll see your graph shows a total of 10
during the entire graph.
{9+1},{8+2},...{2+8},{1+9}

Now, if you compute (with a CDEF) the sum of A and B, and get the max of
that, you will get
max(A+B)=max(9+1,8+2,...2+8,1+9)=max(10,10,10,10,10,10,10,10,10)=10. Which
is what you get using your code.

What Tobi told you will be happening only if you use AVERAGE as your
consolidation function.
If you create a graph where each pixel column shows more than one CDP, then
RRDtool will (for instance) average 8 and 10 into 9, so your max gets lower.
It's definately something to look out for, but I believe in your example it
does not play a role.

```