[rrd-users] Probleme using several dbs and unknown values

Yannick Marquet itcsoft54 at yahoo.fr
Mon Feb 25 21:32:12 CET 2013


Hi unicsonline ,

> In fact the better syntax would be something like :
>
> if period1 != unkown use period1
> else period2 != unkown use period2
> else period3 != unkown use period3
> else use unknown
>
> to preserve unknown values.

They have a arithmetic function to do this (if value aren't both in 
several rra for the same timestamps and correct heartbeat in def of rra) :
ADDNAN (http://oss.oetiker.ch/rrdtool/doc/rrdgraph_rpn.en.html#IArithmetics)

ADDNAN adds two values, if only one is NAN, this value is replace by 
zero, if two values are NAN, NAN is used.

Another solution is to use AVG function, because they ignore UNK values.
(http://oss.oetiker.ch/rrdtool/doc/rrdgraph_rpn.en.html#ISet_Operations)

I hope this solutions can help you.

Yannick Marquet.

Le 30/01/2013 13:21, Simon Hobson a écrit :
> unicsonline wrote:
> I am tracing a long time graph, where datas are dispatched along different dbs
>
> for example for period1, I use db1.rrd, for period2 I use db2.rrd, etc...
>
>
> Of course depending date my infos are present in only one dbs at the same time, and requests sent to an other one returns an unknown value.
>
> My problem is to deal with this unknown values.
>
> In a first try, I have used a workaround with a cdef adding all the values, and replacing unknown ones with a 0 :
>
>
> for example, with 3 periods:
>
> CDEF:TOTAL_period=0,period1,UN,0,period1,IF,+,period2,UN,0,period2,IF,+,period3,UN,0,period3,IF,+
>
> that works, average and max values are ok, but min and last are positionned to 0 (it's normal, because some unknown values are present, and are replaced by 0 in syntax)
>
>
> In fact the better syntax would be something like :
>
> if period1 != unkown use period1
> else period2 != unkown use period2
> else period3 != unkown use period3
> else use unknown
>
> to preserve unknown values.
>
> There are several ways you can do this. One I used in the past when I was switching between two sets fo DBs was to work on date. Basically, if date < some fixed value then use A, else use B. I don't recall the syntax I used (it was a couple of years ago and I no longer have the code lying around), but it wasn't hard.
>
> But if all you want is the simple expression you've given - ie you will only ever use one source - then this would look something like :
>
> A,UN,B,A,IF
> Which means, if A is unknown then use B else use A. You can either use multiple CDEFs (easier to see), just expand the one - I'll put brackets in this one to show the grouping, you take them out to get a valid expression.
> (A,UN),((B,UN),C,B,IF),A,IF
> Which means If A is unknown then use the result of (if B is unknown then use C, else use B), else use A.
> So stripping out the brackets, you getA,UN,B,UN,C,B,IF,A,IF which I think should do what you want - unless I've got it wrong of course !
>
> Bear in mind that if (for example) you consolidate down to daily values, and your data collection switched part way through a day, then you'll have one day when two sources could have a value. Eg if your measured value was a steady 1, and you switched collection at mid day, then A and B would both contain 0.5 for that day. This can be worked around if it's a problem - it just makes the RPN more complicated.
>
> _______________________________________________
> rrd-users mailing list
> rrd-users at lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
>



More information about the rrd-users mailing list