# [rrd-users] Re: How are --start and --end supposed to behave?

Alex van den Bogaerdt alex at ergens.op.het.net
Mon Jan 22 03:36:03 MET 2007

```On Sun, Jan 21, 2007 at 10:39:20PM +0100, Peter Valdemar Mørch wrote:

> In rrdtool version 1.2.15 both "-start 15:00 -end 15:00" and
> "--start 15:00 --end 15:00+1" give one row with a time stamp of
> 1169388300 which is unixtime for 15:05, while "--start 15:00
> --end 15:05" gives two rows, with time stamps 1169388300 and
> 1169388600: 15:05 and 15:10 (that last one being NaN since the
> time is only 15:08)

This is wrong.  Quite some time ago I had a conversation with
range between two times, defined by their end time and step size
times steps.

Time stamp 1169388300 does not mean anything by itself.  It isn't
part of either interval, it is the separator between two intervals.
As an end time, it defines the interval ending at this time.
As a start time, it defines the interval following the interval
ending at this time.

End time 1169388300 should not return rows defining the time range
after 1169388300 unless step*steps is not 300 in this example.

I believe the algoritm to be like this:

Timestamps have no duration.
Always return the interval starting at, or before, the start time.
Always return the interval ending at, or after, the end time.

This means the data returned does at least contain the interval
requested, and possibly more if needed but only if needed.

If step*steps equals 300 and steps==1:
"--start end-300 --end \$((integer * 300))" should return 1 row, not 2.
"--start end-301 --end \$((integer * 300))" should return 2 rows.
"--start end-300 --end \$((integer * 300 +1))" should return 2 rows.
"--start end-302 --end \$((integer * 300 +1))" should return 3 rows.
"--start end --end \$((integer * 300))" should return no rows at all.

> Is this "+1" solution going to work "forever" or are there more changes
> to come? Is there a better way to figure out --start and --end to "get
> the last N samples"?

If everything is as I think it should be, you should be able to:
-1- get the last updated time, or guesstimate it
-2- integer divide by step*steps
-3- multiply by step*steps
-4- use the outcome as your end time
-5- let your start time be step*steps*number_of_rows_requested

Earlier versions (1.0 and early 1.2.x) contained a bug which would return
the row ending at \$start_time.  This has been fixed.  I think you should
be able to get consistent behaviour by asking for
"--start end-299 --end \$((integer * 300))"

Returning a row after \$end_time is a new issue and should probably be
seen as a bug.

HTH
--
Alex van den Bogaerdt
http://www.vandenbogaerdt.nl/rrdtool/

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/rrd-users