[rrd-users] Newbie question: Always missing the last datapoint in rrdtool graphs

Simon Hobson linux at thehobsons.co.uk
Wed Feb 25 22:50:16 CET 2009


Ole Holm Nielsen wrote:

>FYI, my RRD configuration is as follows:  I want to store daily accounting
>data for about 10 years, and this is excerpts from my shell scripts:
>
># Define the earliest possible time (01/01 2002):
>STARTTIME=`$AWK 'BEGIN {print mktime("2002 01 01 00 00 00")}'`
>STEPTIME=86400
>HEARTBEAT=$[$STEPTIME*2]
>$RRDTOOL create $RRDDB \
>          --start $STARTTIME --step $STEPTIME \
>          DS:running:GAUGE:$HEARTBEAT:0:U \
>          DS:DCSC:GAUGE:$HEARTBEAT:0:U \
>          DS:LOCAL:GAUGE:$HEARTBEAT:0:U \
>          RRA:AVERAGE:0.5:1:3650 \
>          RRA:AVERAGE:0.5:7:500 \
>
>I then load several years of accounting data, the timestamp of each
>"rrdtool update" is set to be 23:59:59 on the given day (day,month,year).
>
>Now I want to create a graph for the past week, say, by basically 
>this command:
>
>$RRDTOOL graph $graphfile --end $last --start $starttime \
>                  DEF:running=$RRDDB:running:AVERAGE \
>                  AREA:running$colour_running:"$text_running"
>
>But no matter what guesses I make for $last and $starttime,
>the last day is always missing !
>
>The data point seems to be in there allright:
># rrdtool lastupdate some-database.rrd
>   running DCSC LOCAL
>
>1235516399: 1356.471760 884 343
>where the timestamp translates into Tue 24 Feb 2009 11:59:59 PM CET.
>But the last point in the graph corresponds to Monday 23 Feb !
>
>Question 2: What am I doing wrong in the above database definitions,
>and how should I create the database so that it'll support my needs ?

Try changing your updates to midnight instead of 1 second before midnight.

Two reasons :

1) 1 second before midnight isn't on a step boundary so you are 
forcing rrd tool to normalise the data - 86399 seconds worth into one 
step, and one second into the previous one.

2) Your step period has not ended at 23:59:59 so you won't get any 
data out for the preceding 23:59:59 - until you do another later 
update and rrdtool knows what value is being fed in for that last 
second.

Also, bear in mind that steps are ALWAYS relative to UTC - so if your 
timezone (not mentioned but your email says +1) isn't UTC, then the 
data will be normalised accordingly - eg 'midnight' is really 
23:00:00 UTC and so you will be putting 86339 seconds into one step, 
and 61 seconds into the previous step.

-- 
Simon Hobson

Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.



More information about the rrd-users mailing list