<br>Hello Simon,<br><br>Thanks a lot for this tips ;)<br><br>It seems better but I have now to find how build this formula for any cases, between one db source to x dbsources (nb of periods -so dbs- is variable, and my graph command is generated by script)<br>
<br>For the second remark in this case I have not this problem, because I am sure that I have not more only one values in one db (all others dbs provide unkown values)<br><br><br><div class="gmail_quote">2013/1/30 Simon Hobson <span dir="ltr"><<a href="mailto:linux@thehobsons.co.uk" target="_blank">linux@thehobsons.co.uk</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">unicsonline wrote:<br>
I am tracing a long time graph, where datas are dispatched along different dbs<br>
<br>
for example for period1, I use db1.rrd, for period2 I use db2.rrd, etc...<br>
<br>
<br>
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.<br>
<br>
My problem is to deal with this unknown values.<br>
<br>
In a first try, I have used a workaround with a cdef adding all the values, and replacing unknown ones with a 0 :<br>
<br>
<br>
for example, with 3 periods:<br>
<br>
CDEF:TOTAL_period=0,period1,UN,0,period1,IF,+,period2,UN,0,period2,IF,+,period3,UN,0,period3,IF,+<br>
<br>
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)<br>
<br>
<br>
In fact the better syntax would be something like :<br>
<br>
if period1 != unkown use period1<br>
else period2 != unkown use period2<br>
else period3 != unkown use period3<br>
else use unknown<br>
<br>
to preserve unknown values.<br>
<br>
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.<br>
<br>
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 :<br>
<br>
A,UN,B,A,IF<br>
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.<br>
(A,UN),((B,UN),C,B,IF),A,IF<br>
Which means If A is unknown then use the result of (if B is unknown then use C, else use B), else use A.<br>
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 !<br>
<br>
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.<br>
<br>
_______________________________________________<br>
rrd-users mailing list<br>
<a href="mailto:rrd-users@lists.oetiker.ch">rrd-users@lists.oetiker.ch</a><br>
<a href="https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users" target="_blank">https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users</a><br>
</blockquote></div><br><div style id="__af745f8f43-e961-4b88-8424-80b67790c964__"></div>