# [rrd-users] Aggregation functions for combining whole data sets or averaging over many RRDs

Carsten Aulbert carsten at welcomes-you.com
Sun Mar 23 18:17:03 CET 2008

```Hi Alex,

Alex van den Bogaerdt wrote:

> You can combine those two CDEFs:
>
> CDEF:avg=watin001,watin002...watin024,+,+,...+,24,/

Argh, right I need more experience with RPN, I assumed the stack is just
filled and worked through from right to left - I was wrong.

>
> Be aware of the following: should one (or more) of these DSes become
> unknown, the sum will be unknown.
>

Yes, I already knew that. Yo ucertainly don't want to see how I emulated
the AVG function to cope with that. Let's only say these lines were LONG
and contained a lot if IFs (one for the sum and one for the counting).

> For this reason, AVG exists:  CDEF:x=a,b,c,d,4,AVG

Cool, thanks! I somehow missed these when reading the docs - now I found
them!

>
> One possible problem though: if only one out of 24 is known, that will
> become the 'average'.

Sure, but might be solved by also showing how many non-UNKNOWN values in
the same graph. Related question:

Is there a good way to count the number of non-UNKNOWNs? I would do it
like this (6 values):

CDEF:num=watin001,UN,watin002,UN,watin003,UN,watin004,UN,watin005,UN,watin006,UN,+,+,+,+,+

but again, I might miss something.

Thanks a lot

Carsten

```