[rrd-developers] NAN-safe ADD

Timo Stripf tstripf at gmx.de
Fri Mar 7 00:50:19 CET 2008


Hi Tobi,

i'm running a distributed daemon over several servers. On every 
server rrd files are recorded for usage stats and these files are 
exported by NFS. On one control server all rrd files are combined 
using the ADDNAN operator. If one server was not running the value 
would be NaN and it should be treated as 0. If all values are NaN the 
complete system was not running at this time and the result should be 
NaN to be ignored by the TREND line or year average information.


x=a,UN,0,a,IF,b,UN,0,b,IF,+

is not the same since NaN + NaN would be 0.


An alternative for ADDNAN would be

x=a,UN,b,b,UN,a,a,b,+,IF,IF

and this is getting more complex if you like to add three or more 
values this way. A NANTOZERO operator would not help here.


The ADDNAN operator is associative and commutative.

I also thought about adding NAN-safe versions of other arithmetic 
functions. For subtraction NaN could also be treated as 0 but i found 
no real scenario where this would be useful. For multiplication NaN 
could be treated as the neutral element 1. Reasonable? ... i don't 
know. Division and module are far more complex.

One could think about adding NAN-safe MAX/MIN functions. MAXNAN(a, 
NaN) would be a and not NaN.

Best regards
Timo Stripf


At 06:48 06.03.2008, you wrote:
>Hi Timo,
>
> > On Thu, Mar 06, 2008 at 01:44:30AM +0100, Timo Stripf wrote:
> > > Hello,
> > >
> > > i've implemented a nan-safe add operator (ADDNAN) into rrd. I used it
> > > to add several incomplete graphs.
> > >
> > > NaN + NaN => NaN
> > >  x + NaN => x
> > >  NaN + y => y
> > >  x + y => x + y
> > [...]
> > Quite often 'NaN' does not mean 'nothing'.  In many cases substituting
> > the average of the two neighbours (not direct neighbours per se) would
> > make more sense.
> >
> > At the very least I think this feature deserves more documentation than
> > just a line or two.
>
>How about doing this explicitly:
>
>   x=a,UN,0,a,IF,b,UN,0,b,IF,+
>
>then the effort for doing it has some relationship to the 'danger'
>of the operation.
>
>or if you insist to make this simpler, how about implementing a
>NANTOZERO operator ?
>
>  x=a,NANTOZERO,b,NANTOZERO,+
>
>cheers
>tobi
>
>--
>Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten
>http://it.oetiker.ch tobi at oetiker.ch ++41 62 213 9902
>
>_______________________________________________
>rrd-developers mailing list
>rrd-developers at lists.oetiker.ch
>https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers



More information about the rrd-developers mailing list