[rrd-users] Newbie Question Storing Absolute Values versus Average

Alex van den Bogaerdt alex at ergens.op.het.net
Tue Jun 17 20:24:30 CEST 2008


On Tue, Jun 17, 2008 at 02:11:33PM +0000, guy Fleegman wrote:
> Karl/Alex/All:
> I am still struggling with the idea of why i dont always get whole numbers for
> my data points.

Then you don't understand normalization.  See my site.

> As I understand it... I have 30 second buckets... and every 60 seconds...
> I will update the RRA. This should cause to entries to be updated

Sure.

> However.. what happens looks quite different.. here is the output... and the
> program used below
> 
> ++++++++++OUTPUT++++++++++
> root at nagios:~/Desktop/testrrd# ./script4.sh 
> created.
> 2008-06-17 09:55:20 1213710920 0

1213710920/30 = 40457030.6666666666 which is not a whole multiple of 30.


> return_value = 0
> [1213710870]RRA[MAX][1]DS[in] = 0.0000000000e+00
> [1213710900]RRA[MAX][1]DS[in] = 0.0000000000e+00
> 2008-06-17 09:56:20 1213710980 1

and adding 60 does not help, as the result will still not be a whole
multiple of your step.

> return_value = 0
> [1213710930]RRA[MAX][1]DS[in] = 6.6666666667e-01
> [1213710960]RRA[MAX][1]DS[in] = 6.6666666667e-01
> 2008-06-17 09:57:20 1213711040 2

and adding 60 again does not help

And so one 'bucket' is built from more than one update.

E.g. one third is 0, two thirds is 1, result is 2/3 which is 6.667e-01.


> ++++++PROGRAM++++++++++++++++

Add in front:
TIME=$((date +%s))
TIME=$((TIME/60)) # this is an integer division
TIME=$((TIME*60)) # now TIME is TIME-(TIME modulo 60)

> rrdtool create test4.rrd --start now --step 30 \

Change:
rrdtool create test4.rrd --start $TIME --step 30 \


>                DS:in:GAUGE:120:U:U \
>                RRA:MAX:0.5:1:360
> 
> echo created.
> 
> a=0

Add:
STOP=$((TIME+21600))

> while true; do

Change:

while [ $TIME -lt $STOP ]; do

>   sleep 60

Remove. No need to wait.


>   DATE=( $(date "+%Y-%m-%d %T %s") )
>   echo ${DATE[*]} $a
>   rrdtool updatev test4.rrd ${DATE[2]}:$a

Change these three lines into the following two:

TIME=$((TIME+60))
rrdtool updatev test.4,rrd $TIME:$a


>   a=$(($a+1))
> done

Test, debug, run again, see result.

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



More information about the rrd-users mailing list