From: Peter Stamfest Date: Sun, 24 Aug 2014 21:48:32 +0000 (+0200) Subject: add test playing with different bin sizes X-Git-Tag: v1.5.0-rc1~42^2~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7fc46dda8d17513fa88a616fe5cfd177c12ac98c;p=thirdparty%2Frrdtool-1.x.git add test playing with different bin sizes --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 96488b12..2150d73a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,7 +2,8 @@ TESTS = modify1 modify2 modify3 modify4 modify5 \ tune1 tune2 rpn1 \ rrdcreate \ dump-restore \ - create-with-source-1 create-with-source-2 create-with-source-3 + create-with-source-1 create-with-source-2 create-with-source-3 \ + create-with-source-4 EXTRA_DIST = Makefile.am \ alltests functions \ modify1 modify-test1.create.dump modify-test1.mod1.dump \ diff --git a/tests/create-with-source-4 b/tests/create-with-source-4 new file mode 100755 index 00000000..a141dd70 --- /dev/null +++ b/tests/create-with-source-4 @@ -0,0 +1,87 @@ +#!/bin/bash + +. $(dirname $0)/functions + +BASE=$BASEDIR/$(basename $0)-test +PREFIX=$BUILDDIR/$(basename $0)-test + +# currently, we do not properly copy cdp and pdp information, so for +# comparison of RRD dumps, we just filter out those parts we do not +# expect to match anyway... +function xmlfilter { + +#- 1010 +#- 4.0400000000e+04 +#- 0 +#+ U +#+ 0.0000000000e+00 +#+ 40 + + + perl -n -e '$a=join("",<>); $a=~s,<(cdp_prep|last_ds|value|unknown_sec).*?,,msg ; print $a' +} + +function numberfilter { + perl -n -e '$a=join("",<>); $a=~s,>(\d\.\d\d)\d+,>$1,msg ; print $a' +} + +ST=1300000000 + +rm -f ${PREFIX}*.rrd ${PREFIX}*.xml + +# three different stepped RRDs.... +STEPA=67 +STEPB=73 +STEPAB=71 +MINUPDATE=$(($STEPAB * 2)) + +TOTAL=$((100 * $STEPAB)) + +$RRDTOOL create ${PREFIX}a1.rrd --start $(($ST-1)) --step $STEPA DS:a:GAUGE:$MINUPDATE:0:U RRA:AVERAGE:0.5:1:$(($TOTAL / $STEPA)) RRA:AVERAGE:0.5:5:2 RRA:MIN:0.5:5:2 RRA:MAX:0.5:5:2 RRA:LAST:0.5:5:2 +report createa1 + +$RRDTOOL create ${PREFIX}b1.rrd --start $(($ST-1)) --step $STEPB DS:b:GAUGE:$MINUPDATE:0:U RRA:AVERAGE:0.5:1:$(($TOTAL / $STEPB)) RRA:AVERAGE:0.5:5:2 RRA:MIN:0.5:5:2 RRA:MAX:0.5:5:2 RRA:LAST:0.5:5:2 +report createb1 + +$RRDTOOL create ${PREFIX}ab1.rrd --start $(($ST-1)) --step $STEPAB DS:a:GAUGE:$MINUPDATE:0:U DS:b:GAUGE:$MINUPDATE:0:U RRA:AVERAGE:0.5:1:$(($TOTAL / $STEPAB)) RRA:AVERAGE:0.5:5:2 RRA:MIN:0.5:5:2 RRA:MAX:0.5:5:2 RRA:LAST:0.5:5:2 +report createab1 + + +UPDATEA= +UPDATEB= +V=10 +for A in $(seq $ST $STEPAB $(($ST + $STEPAB * 120)) ) ; do + UPDATEA="$UPDATEA $A:$V" + UPDATEB="$UPDATEB $A:$(($V * 2))" + UPDATEAB="$UPDATEAB $A:$V:$(($V * 2))" + V=$(($V + 20)) + ST=$A +done +$RRDTOOL update ${PREFIX}a1.rrd $UPDATEA +$RRDTOOL update ${PREFIX}b1.rrd $UPDATEB +$RRDTOOL update ${PREFIX}ab1.rrd $UPDATEAB + + + +$RRDTOOL create ${PREFIX}ab2.rrd --start $ST --step $STEPAB --source ${PREFIX}a1.rrd --source ${PREFIX}b1.rrd DS:a:GAUGE:$MINUPDATE:0:U DS:b:GAUGE:$MINUPDATE:0:U RRA:AVERAGE:0.5:1:100 RRA:AVERAGE:0.5:5:2 RRA:MIN:0.5:5:2 RRA:MAX:0.5:5:2 RRA:LAST:0.5:5:2 +report create-ab-with-two-sources + +# now calculate average and standard deviation + +AB1=$($RRDTOOL graph ${PREFIX}ab1.png --imginfo '' --end "$ST" --start end-1h DEF:a=${PREFIX}ab1.rrd:a:AVERAGE DEF:b=${PREFIX}ab1.rrd:b:AVERAGE CDEF:c=b,2,/,a,/ VDEF:s=c,STDEV VDEF:cavg=c,AVERAGE PRINT:s:%lg PRINT:cavg:%lg) +AB2=$($RRDTOOL graph ${PREFIX}ab2.png --imginfo '' --end "$ST" --start end-1h DEF:a=${PREFIX}ab2.rrd:a:AVERAGE DEF:b=${PREFIX}ab2.rrd:b:AVERAGE CDEF:c=b,2,/,a,/ VDEF:s=c,STDEV VDEF:cavg=c,AVERAGE PRINT:s:%lg PRINT:cavg:%lg) + +set -- $AB1 +STDEV1=$1 +AVG1=$2 +set -- $AB2 +STDEV2=$1 +AVG2=$2 + +[ $AVG1 = 1 ] ; report average ab1 == 1 +[ $(dc <<< "$AVG2 1 - 10000 * 1 / p") -lt 10 ] ; report "average ab2 ($AVG2 - 1) < 1/1000" +[ $STDEV1 = 0 ] ; report std dev ab1 == 0 +[ $(dc <<< "$STDEV2 10000 * 1 / p") -lt 20 ] ; report "std dev ab2 ($STDEV2) < 1/500" + + +rm -f ${PREFIX}*.rrd ${PREFIX}*.xml