[rrd-users] Re: first post

Alex van den Bogaerdt alex at ergens.op.het.net
Sat Oct 26 17:24:18 MEST 2002


On Sat, Oct 26, 2002 at 03:59:34PM +0100, Mat Harris wrote:
> 	DEF:myspeed=test.rrd:speed:AVERAGE              \
> 	"CDEF:kmh=myspeed,3600,*"                       \
> 	CDEF:fast=kmh,100,GT,100,0,IF			\
> 	CDEF:over=kmh,100,GT,kmh,100,-,0,IF		\

Always have the manual page at hand.  Do exactly what RRDtool
would do and calculate the stuff by hand.

CDEF:over=kmh,100,GT,kmh,100,-,0,IF

GT does this:                   if a>b return 1 else return 0
and is wriiten down like this:  a,b,GT

-  does this:                   return a - b
and is written down like this:  a,b,-

IF does this:                   if a then b else c
and is written down like this:  a,b,c,IF


Work from left to right: CDEF:over=kmh,100,GT,kmh,100,-,0,IF
CDEF:over= create new variable called over
kmh        get variable kmh and store on stack
           The stack contains one value
100        store 100 onto stack
           The stack contains two values
GT         function!  get the variables a and b and store the result
           Two elements are removed from the stack (leaving none), then
           the result of the GT function is pushed back
           The result is now 1 if kmh is greater than 100
kmh        get variable kmh and store on stack
           The stack contains two values: the result of GT and the
           variable kmh.
100        store 100 onto stack
           The stack contains three values
-          function!  get the variables a and b and store the result
           Two elements are removed from the stack (kmh and 100), then
           the result of the '-' function is pushed back
0          store 0 onto the stack
           The stack now contains: (result of GT),(kmh-100),0
IF         function!  Remove a,b and c from the stack (which is then
           empty) and return either b or c, depending on a.

In other words:
    CDEF:over=kmh,100,GT,kmh,100,-,0,IF
means
    if (kmh > 100)
    then
        return kmh-100
    else
        return 0
    fi


No more additional examples.  I'm having a case of deja vu at the moment.

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list