[rrd-developers] rrdtool fetch behavior?
Mandalemula, Rajesh
Rajesh.Mandalemula at deshaw.com
Wed Feb 10 15:12:13 CET 2010
I am using rrdtool v1.3.8 and rrdfetch seems to be stepping beyond the end time provided (in fact, this appears to be the case with rrdfetch since v1.2.13)
Details:
$ rrdtool --version | head -1
RRDtool 1.3.8 Copyright 1997-2009 by Tobias Oetiker <tobi at oetiker.ch>
$ rrdtool info /tmp/JjT501roge/test.rrd | grep step
step = 5
$ rrdtool last /tmp/JjT501roge/test.rrd
1265722701
$ rrdtool fetch /tmp/JjT501roge/test.rrd AVERAGE -e 1265722701 -s 'end-5'
test1 test2
1265722700: 1.0000000000e+00 4.0000000000e+00
1265722705: -NaN -NaN
# end = last_update - last_update % step
$ echo '1265722701-(1265722701%5)' | bc
1265722700
$ rrdtool fetch /tmp/JjT501roge/test.rrd AVERAGE -e 1265722700 -s 'end-5'
test1 test2
1265722700: 1.0000000000e+00 4.0000000000e+00
1265722705: -NaN -NaN
$
Notice, the unknown values reported for timestamp 1265722705 (which is beyond the requested end time). The code change which produces this behavior seems to from rrdtool v1.2.13 as below:
<<<<< CHANGES BETWEEN v1.2.12 and v1.2.13 rrd_fetch.c >>>>
. . . . . . . . . .
. . . . . . . . . .
@@ -294,7 +294,7 @@
/* set the wish parameters to their real values */
*step = rrd.stat_head->pdp_step * rrd.rra_def[chosen_rra].pdp_cnt;
*start -= (*start % *step);
- if (*end % *step) *end += (*step - *end % *step);
+ *end += (*step - *end % *step);
<<<<< CHANGES BETWEEN v1.2.12 and v1.2.13 rrd_fetch.c >>>>
>From the revision logs:
2006-05-04 12:11 oetiker
* src/rrd_fetch.c: if end % step == 0 we should still fetch a full
step ... no need for special handling
I am curious as to why rrdfetch returns record past the end time, when an explicit end time has been provided. Could you please throw some light on the change in behavior? And, if I need to cope with the new behavior, what should be the correct way to retrieve what I ask for (query for last updated entry)?
Thanks. Rajesh
More information about the rrd-developers
mailing list