File: create-from-template-1

package info (click to toggle)
rrdtool 1.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,772 kB
  • sloc: ansic: 39,371; sh: 1,810; perl: 1,268; cs: 652; makefile: 573; python: 169; ruby: 61; awk: 30
file content (79 lines) | stat: -rwxr-xr-x 2,446 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/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 cdp_prep_filter {
	perl -n -e '$a=join("",<>); $a=~s,<(cdp_prep).*?</\1>,,msg ; print $a'
}

function pdp_prep_filter {
	perl -n -e '$a=join("",<>); $a=~s,<(last_ds|value|unknown_sec).*?</\1>,,msg ; print $a'
}

function data_filter_by_time {
        START="$1"
        END="$2"
#                       <!-- 2011-03-13 08:46:00 CET / 1300002360 --> <row><v>7.9666666667e+02</v>

	perl -n -e 'print unless (m,/ (\d+) -->.*<row>, && $1 >= '$START' && $1 <= '$END')'
}

FIRST=1300000000
ST=$FIRST

RRA="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"

rm -f ${PREFIX}*.rrd ${PREFIX}*.xml
$RRDTOOL create ${PREFIX}ax1.rrd --start $(($ST-1)) --step 60 DS:a:GAUGE:120:0:U DS:b:COUNTER:120:0:U $RRA
report createax1

# Test rrd_first(), #1140
RRD_FIRST=$($RRDTOOL first ${PREFIX}ax1.rrd)
[ $RRD_FIRST = 1299994020 ] ; report rrdtool first == $RRD_FIRST

cp ${BASE}ax1.rrd ${BASE}ax1-copy.rrd

UPDATEAx1=
V=10
for A in $(seq $ST 60 $(($ST + 3000)) ) ; do
	UPDATEAx1="$UPDATEAx1 $A:$V"
	V=$(($V + 20))
	ST=$A
done

$RRDTOOL create ${PREFIX}ay1.rrd --start $ST --step 60 DS:a:GAUGE:120:0:U DS:b:COUNTER:120:0:U $RRA
report createay1

$RRDTOOL update ${PREFIX}ax1.rrd --template a $UPDATEAx1
report update ax1

$RRDTOOL create ${PREFIX}ax2.rrd --template ${PREFIX}ax1.rrd || fail "create ax2"

$RRDTOOL dump ${PREFIX}ay1.rrd > ${PREFIX}ay1.xml
$RRDTOOL dump ${PREFIX}ax2.rrd > ${PREFIX}ax2.xml
$DIFF ${PREFIX}ay1.xml ${PREFIX}ax2.xml

report "created from template matches empty RRD with same start time"

$RRDTOOL create ${PREFIX}b1.rrd --step 60 DS:b:GAUGE:120:0:U  $RRA
report createb1

! $RRDTOOL create ${PREFIX}b2.rrd --template ${PREFIX}b1.rrd  DS:b:COUNTER:120:0:U 2>/dev/null
report "create with template and name-clashing DS fails"

$RRDTOOL create ${PREFIX}ax3.rrd --template ${PREFIX}ax1-copy.rrd \
    --source ${PREFIX}ax1.rrd || fail "create ax3"

$RRDTOOL dump ${PREFIX}ax1.rrd > ${PREFIX}ax1.xml
$RRDTOOL dump ${PREFIX}ax3.rrd > ${PREFIX}ax3.xml
$DIFF ${PREFIX}ax1.xml ${PREFIX}ax3.xml

report "create from old source as template using source for prefilling equals source"

rm -f ${PREFIX}*.rrd ${PREFIX}*.xml