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

Jared Watkins jared at jaredwatkins.com
Tue Apr 5 22:41:27 CEST 2011

```On 4/5/11 4:03 PM, "Alex van den Bogaerdt" <alex at vandenbogaerdt.nl> wrote:

>> 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
>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.
>

Ah.. now I think I get it.  Put another way... the individual circuit
maxes aren't occurring at the same moment so you can't simply add those
max values up and expect to get the total from the stacked values.  This
is because (in our case) the circuits are never going to be perfectly
balanced in traffic volume. This also means the delta between the two
values is a way of representing the amount of imbalance at the time of
peak traffic.  I don't suppose there would be a way to calculate that
value?

Thanks for the help.
Jared

```