[rrd-users] LAST always returning zero
wespvp at msg.bt.com
Fri Mar 7 07:59:43 CET 2008
On 3/6/08 9:59 PM, "Alex van den Bogaerdt" <alex at ergens.op.het.net> wrote:
> The problem: when the original data is unknown, IF branches to true,
> and your CDEF returns 0.
> Solution for you: do not end your graph 'now'. Find the last update
> time, round down to the nearest multiple of your step size, and use
> that as your end. For instance: --end $(($(date +%s)/10*10))
I thought about the undefined values, which is why I tried it without the
IF, expecting it to print 'nan' - but it still printed zero.
Based on your explanation I've been playing with rrdtool fetch on the live
data. I see that it returns the next timestamp after the current time as
all 'nan', plus possibly one additional line of nan's, depending on the last
For example, if the current time is *474, fetch returns:
*460: good data
*470: nan nan nan...
*480: nan nan nan...
Which explains why when I did "now-30", it works. "now-20" usually works,
but sometimes fails, apparently if there is a delay in update. Because of
this, "--end $(($(date +%s)/10*10))" only works some of the time.
I was still confused about my previous tests, but it looks like I must have
made an error when testing things without the IF. I'm not getting the zero
now, but am getting the expected value - the last value stored.
Other data isn't having a problem because I don't have a CDEF IF mucking
with the data, so LAST can find the last actual data point, correct?
So, logically, what I want to do is
CDEF:queue1N=queue1L,0,GT,0,1,IF (or VDEF:queue1N=queue1L,0,GT,0,1,IF)
But I can't do that because a CDEF can't reference a DEF, and a VDEF can't
do the other operations. Right?
Is there not a way to say: --end lastSavedDataPointTime ? I can do the
following, and it appears to work, but it seems rather high overhead:
--end $(($(rrdtool last test.rrd)-10)
I have to do the -10 because "rrdtool last" appears to return the timestamp
of the last second of the time period, not the first second of it.
More information about the rrd-users