[rrd-users] Concatenate 2 RRD without overlap or sum
Simon Hobson
linux at thehobsons.co.uk
Wed Mar 25 11:21:40 CET 2015
topgunx1 <topgunx1 at hotmail.com> wrote:
> Sorry but I'm not so expert in rrd for implementing what you have suggested
> me.
Then treat it as an opportunity to learn !
> Is it possible for you correct my script (I know you are very busy!)?
No, but I'll get you started. See http://oss.oetiker.ch/rrdtool/doc/rrdgraph_rpn.en.html
Assuming you have a DEF of "a" which is the first value you want up until (and including) time t, then this should give you a value up until time t and unknown after that :
CDEF:aa=a,UNKN,TIME,t,LE,IF
Breaking that down:
"TIME,t,LE" means :
Push the time the currently processed value was taken at onto the stack, push the value t onto the stack, if the first was less than or equal to the second then push true onto the stack, else push false.
"a,UNKN,<something>,IF" means :
push a onto the stack, then push unknown onto the stack, then push <something> (the result of the If statement) onto the stack. If that <something> is true then take the a, else take the unknown value.
You need to replace "t" with the numerical value. I tend to use Bash and dynamically generate the RRD scripts, so the above would become "CDEF:aa=a,UNKN,TIME,${t},LE,IF" where t is previously defined/calculated in the script. If you are writing a static script, then use the numerical value.
Further hints.
Don't try to write the whole script and then debug it. Just do one DEF and CDEF and graph that (you should have an area that stops abruptly at time t). When you have that working then you can start adding the other parts.
Don't forget that you need to use "LE and "GT" or "LT" and "GE" depending on whether you want time t to be the older data set or the newer one. If you use LT and GT then there's be a very small gap, if you use LE and GE then both sets will be included at time t and there's be a blip in the data.
More information about the rrd-users
mailing list