[rrd-developers] rrdtool: update fails on negative timestamp
Tobias Oetiker
tobi at oetiker.ch
Mon Jun 1 15:57:41 CEST 2009
Hi Sebastian,
I have included the following patch:
Index: src/rrd_update.c
===================================================================
--- src/rrd_update.c (revision 1808)
+++ src/rrd_update.c (working copy)
@@ -972,6 +972,11 @@
return -1;
};
setlocale(LC_NUMERIC, old_locale);
+ if (tmp < 0.0){
+ gettimeofday(&tmp_time, 0);
+ tmp = (double)tmp_time.tv_sec + (double)tmp_time.tv_usec * 1e-6f + tmp;
+ }
+
*current_time = floor(tmp);
*current_time_usec = (long) ((tmp - (double) *current_time) * 1e6f);
}
this should take care of the problem ...
cheers
tobi
Today Sebastian Harl wrote:
> Hi Tobi,
>
> On Fri, Apr 10, 2009 at 09:57:30PM +0200, Tobias Oetiker wrote:
> > Today Sebastian Harl wrote:
> > > On Tue, Apr 07, 2009 at 10:11:57PM +0200, Sebastian Harl wrote:
> > > > On Tue, Apr 07, 2009 at 07:35:30PM +0200, Tobias Oetiker wrote:
> > > > > Today Sebastian Harl wrote:
> > > > > > $ rrdtool update file.rrd -t ds -- -5:42 && date
> > > > > > ERROR: file.rrd: illegal attempt to update using time -5 when last update
> > > > > > time is 1239115940 (minimum one second step)
> > > > > > 1239116951
> > > > > >
> > > > > > Apparently, this feature got lost somewhere on the way.
> [...]
> > > The rrdupdate(1) manpage states the following:
> > >
> > > N|timestamp:value[:value...]
> > >
> > > The data used for updating the RRD was acquired at a certain time.
> > > This time can either be defined in seconds since 1970-01-01 or by
> > > using the letter ?N?, in which case the update time is set to be the
> > > current time. Negative time values are subtracted from the current
> > > time. [...]
> > >
> > > So, I'd expect the following to happen:
> > >
> > > When using N:<values>, RRDtool calls time() to get the current time (in
> > > seconds since the epoch) and uses that as timestamp when storing the
> > > values. That works fine.
> > >
> > > When using 1234567890:<values>, RRDtool uses the given timestamp (in
> > > seconds since the epoch). That works fine as well.
> > >
> > > When using -5:<values>, RRDtool calls time() to get the current time (in
> > > seconds since the epoch) and subtracts 5 (in this case) from it. The
> > > result will be used as timestamp when storing the values. That does not
> > > currently work, but, instead, fails with the error mentioned in the
> > > example above.
> > >
> > > So, now, the question is: Did I misunderstand the manpage? I'm not sure
> > > how to interpret the last sentence (from the quote above) then and I'd
> > > appreciate an explanation. Else, did that feature ever exist? If not,
> > > why is it documented in the manpage? How should it behave in the future?
> > > I.e., either the manpage or rrdupdate(1) should be fixed ...
> >
> > ah ... now I get it ... the -5 should work ... will check ...
>
> Any news on that?
>
> Cheers,
> Sebastian
>
>
--
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch tobi at oetiker.ch ++41 62 775 9902 / sb: -9900
More information about the rrd-developers
mailing list