pmrep: further zbxsend python3 fixes
[pcp.git] / qa / 948
blob56b1dc95076bbbb6a1ca2f59f498a96364523341
1 #!/bin/sh
2 # PCP QA Test No. 948
3 # pmlogger local context functionality
5 # Copyright (c) 2015 Red Hat. 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 cd $here
19 $sudo rm -rf $tmp.*
20 $sudo $PCP_RC_DIR/pcp start | _filter_pcp_start
23 status=1 # failure is the default!
24 $sudo rm -rf $tmp.* $seq.full
25 trap "_cleanup; exit \$status" 0 1 2 3 15
27 cat <<End-of-File >$tmp.config
28 log mandatory on 1 sec {
29 kernel.all.hz
30 hinv.pagesize
31 sampledso.long.million
33 End-of-File
35 _filter_kernel()
37 sed \
38 -e "s/value $hertz$/value HZ/g" \
39 -e "s/value $pagesz$/value PAGESZ/g" \
40 -e 's/TIMESTAMP / /g' \
41 #end
44 _filter_usage()
46 sed -e '/^Options:/{
48 s/.*/.../
53 # Unable to connect to pmlogger pid 28124 at local:: Connection refused
54 # Connected to pmlogger pid 25625 at local:
55 _filter_pmlc()
57 sed \
58 -e "/^Unable/s/ $pid / PID /" \
59 -e "/^Connected/s/ $pid / PID /" \
60 # end
63 # real QA test starts here
64 echo "=== error cases ===" | tee -a $seq.full
65 rm -f $tmp.0 $tmp.meta $tmp.index $tmp.log
66 pmlogger -c /dev/null -o -h localhost $tmp -l $tmp.log 2>&1 | _filter_usage
67 [ -f $tmp.log ] && cat $tmp.log >>$seq.full
69 echo | tee -a $seq.full
70 echo "=== linger tests ===" | tee -a $seq.full
71 echo "--- expect error from pmlc ---" | tee -a $seq.full
72 rm -f $tmp.0 $tmp.meta $tmp.index $tmp.log
73 pmlogger -c /dev/null -o -l $tmp.log $tmp &
74 pid=$!
75 echo "pid=$pid" >>$seq.full
76 cat <<End-of-File >$tmp.pmlc
77 quit
78 End-of-File
79 sleep 1
80 pmlc -e <$tmp.pmlc $! 2>&1 | _filter_pmlc
81 if ps -p $pid >/dev/null
82 then
83 echo "Error: pmlogger still alive!"
84 kill -TERM $pid
86 [ -f $tmp.log ] && cat $tmp.log >>$seq.full
88 echo "--- expect success from pmlc ---" | tee -a $seq.full
89 rm -f $tmp.0 $tmp.meta $tmp.index $tmp.log
90 pmlogger -c /dev/null -L -o -l $tmp.log $tmp &
91 pid=$!
92 echo "pid=$pid" >>$seq.full
93 sleep 1
94 pmlc -e <$tmp.pmlc $! 2>&1 | _filter_pmlc
95 if ps -p $pid >/dev/null
96 then
97 kill -TERM $pid
98 else
99 echo "Error: pmlogger has died!"
101 [ -f $tmp.log ] && cat $tmp.log >>$seq.full
103 echo | tee -a $seq.full
104 echo "=== OK case ===" | tee -a $seq.full
105 hertz=`pmprobe -v kernel.all.hz | $PCP_AWK_PROG '{ print $3 }'`
106 pagesz=`pmprobe -v hinv.pagesize | $PCP_AWK_PROG '{ print $3 }'`
108 # ensure pmcd is unavailable while this test is running
109 $sudo $PCP_RC_DIR/pcp stop | _filter_pcp_stop
110 rm -f $tmp.0 $tmp.meta $tmp.index $tmp.log
111 pmlogger -c $tmp.config -l $tmp.log -T 5 --local-PMDA -K add,30,$PCP_PMDAS_DIR/sample/pmda_sample.$DSO_SUFFIX,sample_init $tmp >$tmp.err 2>&1
113 _filter_pmlogger_log <$tmp.log
115 echo "verifying the archive"
116 pmlogcheck $tmp
118 # expect 4, 5 or 6 sample lines for each metric
119 echo PAGESZ samples:
120 pmdumplog $tmp \
121 | _filter_pmdumplog \
122 | grep 'hinv.pagesize' \
123 | _filter_kernel \
124 | sed -e 5d -e 6d
125 echo HZ samples:
126 pmdumplog $tmp \
127 | _filter_pmdumplog \
128 | grep 'kernel.all.hz' \
129 | _filter_kernel \
130 | sed -e 5d -e 6d
131 echo MILLION samples:
132 pmdumplog $tmp \
133 | _filter_pmdumplog \
134 | grep 'sampledso.long.million' \
135 | _filter_kernel \
136 | sed -e 5d -e 6d
138 echo "Full log dump:" >> $seq.full
139 pmdumplog $tmp >> $seq.full
141 # success, all done
142 status=0
143 exit