Dealing with NaN's when summing across multiple RRD files

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
Phix
Posts: 5
Joined: Sat Feb 07, 2009 4:52 am

Dealing with NaN's when summing across multiple RRD files

Post by Phix »

Hi all,

I have done a quick search for this on the forums but nothing immediately showed up. Here's my question/problem.

I have a collection of RRD files, say, 0-9 (file0.rrd, file1.rrd .... file9.rrd) all with the same data source names in them, and what I require is to graph the sum of each data source across all RRD files.

For example, let's say there is a data source called "count" in each file. I need to calculate file0.rrd:count+file1.rrd:count+file2.rrd:count ... file9.rrd:count, and then graph this value.

So far, I have managed to bring each of these data sources into a graph template, and then use the notation that cacti uses to sum using CDEFs. For example, to get the summation of the above, I could just use this very simple CDEF in a graph template and then graph it.

Code: Select all

a,b,c,d,e,f,g,h,i,j,+,+,+,+,+,+,+,+,+
My first question then is in relation to NaNs. If any one of these values, a-j, is a NaN, does that mean the entire CDEF above evaluates to a NaN?

If this is the case, I then need some CDEF that converts NaNs to 0s before summing. Maybe something like this:

Code: Select all

a,NaN,EQ,0,a,IF,b,NaN,EQ,0,b,IF,c,NaN,EQ,0,c,IF,d,NaN,EQ,0,d,IF,e,NaN,EQ,0,e,IF,f,NaN,EQ,0,f,IF,g,NaN,EQ,0,g,IF,h,NaN,EQ,0,h,IF,i,NaN,EQ,0,i,IF,j,NaN,EQ,0,j,IF,+,+,+,+,+,+,+,+,+
but this does seem to give me strange results (eg. graphs zero even though I know at least one of the RRD files contains non-zero information).

Can anybody advise on a better method of dealing with this problem? Or give me any pointers as to a better way of approaching it? Is there a more "correct" way of testing if a value is a NaN rather than the IF approach above?

Thanks.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please use UN:
UN, ISINF

Pop one element from the stack, compare this to unknown respectively to positive or negative infin-
ity. Returns 1 for true or 0 for false.
Reinhard
Phix
Posts: 5
Joined: Sat Feb 07, 2009 4:52 am

Post by Phix »

Cheers, that worked brilliantly. :-)
devilnct
Posts: 8
Joined: Thu Aug 15, 2013 1:24 am

Re: Dealing with NaN's when summing across multiple RRD file

Post by devilnct »

Dear Phix & gandalf,

I have a problem like Phix, but I don't know how to use UN, ISINF, I tried many ways:

- a,b,c,d,+,+,+,UN -> fail
- a,b,c,d,UN,+,+,+ -> fail
- a,UN,b,UN,c,UN,d,UN,+,+,+ -> fail
- a,UN,a,b,UN,b,c,UN,c,d,UN,d,+,+,+ -> fail

How can I use UN, ISINF ?

Thank you very much, sorry for my english.
devilnct
Posts: 8
Joined: Thu Aug 15, 2013 1:24 am

Re: Dealing with NaN's when summing across multiple RRD file

Post by devilnct »

Dear,

I can use UN but I have a problems: the value current of graph is 0 ?
How can I fix it ?
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests