4 # Derived metrics - exercise pmFetch processing
6 # Copyright (c) 2009 Ken McDonell. All Rights Reserved.
10 echo "QA output created by $seq"
12 # get standard environment, filters and checks
17 if grep -q 'pmRegisterDerived' $PCP_INC_DIR/pmapi.h
21 echo "No derived metric support" >$seq.notrun
22 echo "$seq: [not run] `cat $seq.notrun`"
26 # For this test, don't load any global derived metric configs by default.
27 # So the PCP_DERIVED_CONFIG environment variable is set to an empty string.
28 export PCP_DERIVED_CONFIG
=""
30 status
=0 # success is the default!
31 $sudo rm -rf $tmp.
* $seq.full
32 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
34 # Derived metric expr dump from 0x8513a48...
35 # expr node 0x867eb68 type=PLUS left=0x867eb98 right=0x867ed28
38 cat $tmp.out
>>$seq.full
39 awk <$tmp.out
>$tmp.
sed '
41 $1 == "expr" && $2 == "node" && $3 ~ /^0x/ { print "s/" $3 "/<addr-" n ">/"; n++ }
43 echo "=== sed ===" >>$seq.full
44 cat $tmp.
sed >>$seq.full
45 sed -f $tmp.
sed <$tmp.out \
47 -e '/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/s/[^ ]*.*numpmid/TIMESTAMP ... numpmid/' \
48 -e 's/=0x0 /=(nil) /g' \
50 # -e 's/ val=[0-9][0-9]*/ val=<number>/g'
53 # expr node <addr-6> type=NAME left=(nil) right=(nil) save_last=1 [sample.pdu] master=0
55 # [0] inst=-1, val=49794
58 sed <$tmp.out
-e 's/val=/val /' \
61 /expr.*sample\./ { want=1; next }
62 want == 1 && $3 == "val" { if (seen[$4] != "y") {
63 print "s/ val=" $4 "$/ val=<value-" n ">/"
68 $1 == "expr" { want = 0 }'
69 echo "=== sed2 ===" >>$seq.full
70 cat $tmp.sed2
>>$seq.full
74 # real QA test starts here
76 echo "No errors here ..." |
tee -a $seq.full
77 cat <<End-of-File >$tmp.config
78 # simple constant, no arithmetic
80 # simple renaming to test all data types ... no arithmetic
81 myname.a = sample.long.million
82 myname.b = sample.longlong.million
83 myname.c = sample.float.million
84 myname.d = sample.double.million
85 myname.e = sample.string.null
86 myname.f = sample.string.hullo
87 myname.g = sample.string.write_me
89 myname.h = sample.long.million + sample.long.hundred + sample.long.ten + sample.long.one
90 myname.i = sample.longlong.million - sample.longlong.hundred - sample.longlong.ten - sample.longlong.one
91 myname.j = sample.float.million - sample.float.hundred * sample.float.ten / sample.float.one
92 myname.k = sample.long.million - ( sample.float.hundred * sample.double.hundred * sample.longlong.hundred ) + sample.long.one
93 # arithmetic over sets of values (instance domains)
94 myname.l = sample.bin / 50
95 myname.m = 3*sample.bin
96 myname.n = sample.bin + sample.bucket*2 - (sample.bin + 100) - sample.bucket
97 # arithmetic over mix of singleton (null indom) and value sets (instance domains)
98 myname.o = sample.bin * sample.double.ten
99 myname.p = sample.double.ten * sample.bin
104 for args
in myname.const myname.a myname
"myname.a sample.long" \
105 "sample.long myname.a" "sample.longlong myname.a myname.b sample.long" \
106 "sample.string myname.f sample.bin myname"
108 echo |
tee -a $seq.full
109 echo "=== $args ===" |
tee -a $seq.full
110 pminfo
-c $tmp.config
-Dfetch,derive
,appl2
-f $args >$tmp.out
2>&1
114 echo |
tee -a $seq.full
115 echo "All the arithmetic operators and operand types ..." |
tee -a $seq.full
116 cat <<End-of-File >$tmp.config
117 arith.l = sample.load - sample.load + sample.load / sample.load * sample.load - sample.load
118 arith.ul = sample.daemon_pid - sample.daemon_pid + sample.daemon_pid / sample.daemon_pid * sample.daemon_pid - sample.daemon_pid
119 arith.ll = sample.longlong.hundred - sample.longlong.hundred + sample.longlong.hundred / sample.longlong.hundred * sample.longlong.hundred - sample.longlong.hundred
120 arith.ull = sample.ulonglong.hundred - sample.ulonglong.hundred + sample.ulonglong.hundred / sample.ulonglong.hundred * sample.ulonglong.hundred - sample.ulonglong.hundred
121 arith.f = sample.float.hundred - sample.float.hundred + sample.float.hundred / sample.float.hundred * sample.float.hundred - sample.float.hundred
122 arith.d = sample.double.hundred - sample.double.hundred + sample.double.hundred / sample.double.hundred * sample.double.hundred - sample.double.hundred
123 arith.promote.l_l_r_ll = sample.long.one + sample.longlong.hundred
124 arith.promote.l_ll_r_l = sample.longlong.hundred + sample.long.one
125 arith.promote.l_ll_r_ul = sample.longlong.hundred + sample.ulong.one
126 arith.promote.l_ull_r_l = sample.ulonglong.hundred + sample.long.one
127 arith.promote.l_l_r_ull = sample.long.one + sample.ulonglong.hundred
128 arith.promote.l_ul_r_ull = sample.ulong.one + sample.ulonglong.hundred
129 arith.promote.l_ull_r_ul = sample.ulonglong.hundred + sample.ulong.one
130 arith.promote.l_l_r_f = sample.long.one + sample.float.hundred
131 arith.promote.l_ul_r_f = sample.ulong.one + sample.float.hundred
132 arith.promote.l_ll_r_f = sample.longlong.one + sample.float.hundred
133 arith.promote.l_ull_r_f = sample.ulonglong.one + sample.float.hundred
134 arith.promote.l_f_r_l = sample.float.hundred + sample.long.one
135 arith.promote.l_f_r_ul = sample.float.hundred + sample.ulong.one
136 arith.promote.l_f_r_ll = sample.float.hundred + sample.longlong.one
137 arith.promote.l_f_r_ull = sample.float.hundred + sample.ulonglong.one
138 arith.eval.mul.l_l_r_l = sample.long.ten * sample.long.hundred
139 arith.eval.mul.l_ull_r_ull = sample.ulonglong.ten * sample.ulonglong.hundred
140 arith.eval.div.l_f_r_f = sample.float.hundred / sample.float.ten
141 arith.eval.div.l_zero_f_r_f = 0 / sample.float.ten
142 arith.eval.div.l_zero_d_r_d = 0 / sample.double.ten
143 arith.eval.op.l_err = sample.needprofile + 1
144 arith.eval.op.r_err = 1 + sample.needprofile
149 pminfo
-c $tmp.config
-Dderive,appl2
-f arith
>$tmp.out
2>&1
150 _filter
<$tmp.out | _filter2
152 echo |
tee -a $seq.full
153 echo "Errors and empty results here ..." |
tee -a $seq.full
154 cat <<End-of-File >$tmp.config
155 myname.a = sample.needprofile
156 myname.b = 100 + sample.long.hundred * ( 2 - sample.needprofile )
157 myname.c = sample.needprofile - sample.not_ready
158 myname.d = sample.not_ready - sample.needprofile
159 myname.e = sample.noinst
160 myname.f = ( sample.long.hundred + sample.long.one ) * ( sample.noinst - 1 )
167 echo |
tee -a $seq.full
168 echo "=== $args ===" |
tee -a $seq.full
169 pminfo
-c $tmp.config
-Dfetch,derive
,appl0
,appl2
-f $args >$tmp.out
2>&1