[rrd-users] One-off and no-data-problem

Simon Hobson linux at thehobsons.co.uk
Thu Dec 30 12:44:51 CET 2010


Jonatan Magnusson wrote:

>So I've created a tiny shell script that creates a database, put a
>single value in it and then print the contents:
>
>      #!/bin/sh
>
>      RRD=test.rrd
>      STEP=300
>      HB=600
>
>      # Remove previous databse to be sure that
>      # old data does not affect the test
>      rm -f $RRD
>
>      # Create database
>      rrdtool create $RRD \
>          --start 2999999999 --step $STEP \
>          DS:a:GAUGE:$HB:U:U \
>          RRA:AVERAGE:0.5:1:1000
>
>      # Do a single update
>      rrdtool update $RRD \
>          3000000400:123
>
>      # Fetch data and print to stdout
>      rrdtool fetch $RRD \
>          --start 3000000000 --end 3000000900 AVERAGE
>
>I would expect this to print three (or perhaps four, not sure about the
>last one) values like this:
>
>      3000000000: -nan
>      3000000300: 123
>      3000000600: -nan
>      3000000900: -nan
>
>But this is what I get:
>
>      3000000300: -nan
>      3000000600: -nan
>      3000000900: -nan
>      3000001200: -nan
>
>So there's three differences:
>
>1. Why does the fetch command start at 300, instead of 0?

Because the database does not have any data for the period ENDING at 0

>2. Why does the fetch command include not only the last step (900) but
>also one more (1200)?

Not sure

>3. Why was not the updated value accepted?

It was, but it's not enough for rrd tool to calculate a value for the 
whole period.It knows that at time 400 the value was 123. Before that 
it has to assume the values are unknown as you've not supplied any 
earlier updates.

After that time, it cannot calculate the value for the period ENDING 
at 600 because it doesn't have sufficient data. You could do an 
update at time 401, or you might not do another update until the 
heartbeat period has expired (in which case the whole period would 
unknown.

You need to do a second update on or after time 600, but before time 
1000 (400+600) when the value will be reverted to unknown. Only then 
will you get an output at time 600.

Also, unless the next update (on or after time 600) is also 123, then 
you won't get 123 as the result.

You may well find it useful to read Alex's tutorials at 
http://www.vandenbogaerdt.nl/rrdtool/
Specifically "Rates, normalizing and consolidating"

-- 
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