[rrd-users] Re: MAX function in CDEF

Alex van den Bogaerdt alex at ergens.op.het.net
Tue Sep 24 23:44:41 MEST 2002


On Tue, Sep 24, 2002 at 06:40:58PM +0200, Radovan Turan wrote:

> And this is problem. By manual page, "CDEF:y=x1,x2,MAX" is the propper
> function to select maximum of the values x1 and x2. But "y" is leaved
> "UNKNOWN".


max(unknown,unknown) == unknown
max(known,unknown) == unknown
max(unknown,known) == unknown
max(known,known) == known

So, if either x1 or x2 (or both) are unknown, so will be the result.

Solution:

if (x1==unknown)
then
	return x2
elsif (x2==unknown)
then
	return x1
else
	return max(x1,x2)
fi


In RPN (may need some debugging which I didn't do!):

x1,UN,x2,result_of_next,IF    (this is the if-then)

result_of_next:
x2,UN,x1,result_next,IF       (this is the elsif-then)

result_next:
x1,x2,MAX                     (in case both x1 and x2 are known)


Combined:

CDEF:y=x1,UN,x2,x2,UN,x1,x1,x2,MAX

This function:

  f(unknown1,unknown2) == unknown2
  f(known1,unknown2) == known1
  f(unknown1,known2) == known2
  f(known1,known2) == max(known1,known2)

will return an unknown only if both x1 AND x2 are unknown.
The original function will return unknown if x1 OR x2 are unknown.

HTH
Alex

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