[rrd-users] Help with RPN: divide the sum of two sets

Graham Leggett minfrin at sharp.fm
Wed Dec 15 03:54:04 CET 2010


Hi all,

I am struggling with some reverse polish notation which is giving me  
"zero" for every point.

What I'm trying to do is sum the values from a number of RRD graphs,  
and then divide that by the sum of values from another set of RRD  
graphs (giving me total bytes per hit in my case).

If there is only one DEF in the bytes set, and one DEF in the count  
set, I get reverse polish notation that looks like this, and this works:

CDEF:cost=bysize200,bycount200,/

The trouble is, as soon as I have two DEFs in the bytes set, and two  
DEFs in the count set, I get a graph containing all points at zero:

CDEF:cost=bysize400,bysize200,+,bycount400,bycount200,+,/

My thinking is that bysize400 and bysize200 are pushed onto the stack,  
then added together, leaving one figure on the stack (the sum of  
bysize). Then bycount400 and bycount200 are pushed onto the stack, and  
added together, leaving two figures on the stack (the sum of bysize,  
followed by the sum of bycount). FInally, we divide one by the other  
to get the result.

In practice, this doesn't work, the answer to this calculation is  
always zero.

Can anyone point out what I have done wrong?

Regards,
Graham
--



More information about the rrd-users mailing list