[rrd-users] RRDs Coding Question - Dynamic Multiple RRD Data Sources

Simon Hobson linux at thehobsons.co.uk
Wed Sep 26 08:38:29 CEST 2012

Wesley Wyche wrote:

>            "CDEF:usravg=usrdat,1,1,*,*",
>            "CDEF:nicavg=nicdat,1,1,*,*",
>            "CDEF:sysavg=sysdat,1,1,*,*",
>            "CDEF:idlavg=idldat,1,1,*,*",
>Don't understand why I would waste cycles multiplying by 1 twice, but that
>was the code I originally found in an example script long ago.

And you go propagating it onwards. It does nothing but (as you say) 
waste CPU cycles. Just drop it.



>The graph is generated, but i get a single line in the middle.

Don't forget that in these calculations, if ANY value is unknown 
(NAN) then the sum of that and the other values will also be unknown.

There are two ways round this, one being to convert the unknowns to zero :

(if a is unknown then choose 0, else choose a)
but this will mean you always get a line on the graph even if there 
is no data at all.

Or if you want to preserve there being no data at some points, then 
it's a bit more involved (not a lot)
(if a is unknown, then choose b, else choose a+b)
At this point, you either have a number (a+b), or unknown if a and b 
are unknown. Then :
which adds c into the mix. Repeat as required.
You can of course roll up a whole lot into one RPN expression which 
will become somewhat hard to follow later !

Bear in mind that (unless you avoid consolidation altogether) then 
you cannot add MIN and MAX values together. Consider the case where, 
at every update, the values total to 1 - but the distribution is such 
that occasionally that unit may go to just one RRD. Also, over time, 
the distribution is such that all the RRDs get 1/4.
Once consolidated, you'll find that average is 0.25, but min is 0, 
and max is 1 in each RRD. However, we never had more than 1 in any 
update, nor did we ever have less than 1. Somehow we've ended up with 
a min of 0, and a max of 4.

Simon Hobson

Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.

More information about the rrd-users mailing list