Merge branch 'master' of git://git.pcp.io/pcp into qt
[pcp.git] / qa / 529
blob2ba0830643c33e6466e42f297e2ba6e617cb4010
1 #! /bin/sh
2 # PCP QA Test No. 529
3 # verify the pmcd.pmie metrics from the pmcd PMDA
5 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
12 . ./common.product
13 . ./common.filter
14 . ./common.check
16 _cleanup()
18 if [ ! -z "$pid3" ]
19 then
20 $sudo rm -f $PCP_TMP_DIR/pmie/$pid3
21 $signal -s TERM $pid3
22 pid3=''
24 if [ ! -z "$pid4" ]
25 then
26 $sudo rm -f $PCP_TMP_DIR/pmie/$pid4
27 $signal -s TERM $pid4
28 pid4=''
32 signal=$PCP_BINADM_DIR/pmsignal
33 status=1 # failure is the default!
34 trap "_cleanup; $sudo rm -f $tmp.*; exit \$status" 0 1 2 3 15
35 username=`id -u -n`
36 host=`pmhostname`
38 _filter()
40 sed \
41 -e 's/.*value //' \
42 -e "s,/var$tmp,TMP,g" \
43 -e "s,$tmp,TMP,g" \
44 -e "s;/privateTMP;TMP;g" \
45 -e "s/$host/HOST/g" \
46 -e "s/`hostname`/HOST/g" \
47 -e "s/localhost\.localdomain/MYHOST/g" \
48 -e "s/localhost/HOST/g" \
49 -e "s/local:/HOST/g" \
50 | $PCP_AWK_PROG '
51 NR == 1 { big = $1; next }
52 $1 > big { big = $1 }
53 END { print big }'
56 rm -f $seq.full
58 # real qa test starts here
60 echo === checking unknown, numrules, actions, expected, true
61 cat <<End-of-File >$tmp.conf
62 // the rules
64 all_sample ( sample.long.ten @0..3 < 10 ) -> print "rule1: (BAD)" " %v < 10";
65 all_sample ( sample.long.ten @0..3 >= 10 ) -> print "rule2: (OK)" " %v >= 10";
66 sample.long.ten < 10 -> print "rule3: (BAD)" " %v < 10";
67 sample.long.ten >= 10 -> print "rule4: (OK)" " %v >= 10";
68 End-of-File
70 __user=root
71 id pcp >/dev/null 2>&1 && __user=pcp
73 _start_up_pmie1()
75 cat >$tmp.cmd1 <<End-of-File
76 #!/bin/sh
77 pmie \$@ &
78 echo pid=\$!
79 End-of-File
81 $sudo -u $__user sh $tmp.cmd1 $@ $tmp.conf >$tmp.pid
82 eval `cat $tmp.pid`
85 _start_up_pmie2()
87 cat >$tmp.cmd2 <<End-of-File
88 #!/bin/sh
89 pmie \$@ <$tmp.conf &
90 echo pid=\$!
91 End-of-File
93 $sudo -u $__user sh $tmp.cmd2 $@ >$tmp.pid
94 eval `cat $tmp.pid`
97 pmieopts="-v -b"
98 _start_up_pmie1 -t 1sec -T 4sec $pmieopts -l $tmp.out1
99 pid1=$pid
100 _start_up_pmie2 -t 1sec -T 4sec $pmieopts -l $tmp.out2
101 pid2=$pid
102 echo "self=$$ pid1=$pid1 and pid2=$pid2" >> $seq.full
104 sleep 2
106 # link the pmie mmap'd files so they persist after the pmie processes
107 # exit
109 sleep 1000 &
110 pid3=$!
111 sleep 1000 &
112 pid4=$!
113 $sudo ln $PCP_TMP_DIR/pmie/$pid1 $PCP_TMP_DIR/pmie/$pid3
114 $sudo ln $PCP_TMP_DIR/pmie/$pid2 $PCP_TMP_DIR/pmie/$pid4
116 echo "log mandatory on default { pmcd.pmie }" \
117 | pmlogger -t 0.25sec -T 5sec $tmp
119 sleep 4
121 echo "log from pid=$pid1" >> $seq.full
122 cat $tmp.out1 >> $seq.full
123 echo "log from pid=$pid2" >> $seq.full
124 cat $tmp.out2 >> $seq.full
126 # values at the end of the run should be deterministic for these metrics...
127 # ... metrics are instantaneous, so 10 samples reported in 9 secs
129 # numrules = 4
130 # expected = 4 rule evaluations every 1 sec (4.0)
131 # configfile = "<stdin>" and /tmp/[PID].conf
133 # actual = 20
134 # unknown = 6
135 # true = 7
136 # false = 7
137 # actions = 7
140 for pid in $pid3 $pid4
142 echo
143 [ $pid = $pid3 ] && echo "first pmie instance ..."
144 [ $pid = $pid4 ] && echo "second pmie instance ..."
145 echo "pid=$pid ..." >>$seq.full
147 for metric in configfile logfile pmcd_host numrules actions \
148 eval.true eval.false eval.unknown eval.expected eval.actual
150 $PCP_ECHO_PROG $PCP_ECHO_N "$metric ""$PCP_ECHO_C"
151 echo "$metric ..." >>$seq.full
152 pmdumplog $tmp pmcd.pmie.$metric \
153 | tee -a $seq.full \
154 | grep $pid \
155 | _filter
156 done
157 done
159 # success, all done
160 status=0
161 exit