[rrd-users] Re: MAX function in CDEF

Radovan Turan rturan at in.nextra.sk
Wed Sep 25 14:47:41 MEST 2002


That's the problem. I had one rrd file with inpropper data.
And when I used GE version, graph was O.K because

GE(unknown, known) = known ... :-(((

Thanks for hint.

And when someone else will need this - with Milan Obuch big help, this is
solution, how to obtain the biggest value from the 3 inputs:

DEF:x1=....
DEF:x2=....
DEF:x3=....

CDEF:biggest=x1,x2,GE,x1,x2,IF,x3,GE,x1,x2,GE,x1,x2,IF,x3,IF

or much more efficient & readable:

CDEF:biggest=x1,x2,GE,x1,x2,IF,DUP,x3,GE,EXC,x3,IF

Problem solved, you can close the thread :-)

-- 
Rado1

On Tue, Sep 24, 2002 at 11:44:41PM +0200, Alex van den Bogaerdt wrote:
#> 
#> 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
#> 

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