pmrep: update TODO, man page
[pcp.git] / qa / 322
blobcb5b32d26111f849ea576e6fa36da8e05377429e
1 #! /bin/sh
2 # PCP QA Test No. 322
3 # pmlogger (assorted) and pmlc (PCP 2.0) version compatibility
4 # any host version ... see 374 for 64-bit host version
6 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
9 seq=`basename $0`
10 echo "QA output created by $seq"
12 # get standard filters
13 . ./common.product
14 . ./common.filter
15 . ./common.check
17 rm -f $seq.full
19 _filter()
21 _filter_pmdumplog \
22 | sed \
23 -e '/^pmlogger .* on host .* is logging metrics from host .*/d' \
24 -e '/^PMCD host/d' \
25 -e '/^TIMESTAMP started/d' \
26 | $PCP_AWK_PROG '
27 /datax/ { skip = 3 }
28 skip > 0 { skip--; next }
29 $1 == "log" && $2 == "size" { if ($3 > 100 && $3 <= 200) $3 = "more than 100"
30 else if ($3 > 200 && $3 <= 300) $3 = "more than 200"
32 { print }'
35 _remote_signal()
37 host="$1"
38 pid="$2"
39 base="$3"
41 cat <<end-of-file >$tmp.cmd
42 . \$PCP_DIR/etc/pcp.env
43 \$PCP_BINADM_DIR/pmsignal -s TERM $pid
44 sleep 1
45 \$PCP_BINADM_DIR/pmsignal -s KILL $pid
46 test -k \$PCP_TMP_DIR/pmlogger || sudo chmod o-w \$PCP_TMP_DIR/pmlogger
47 rm -f /tmp/$base.*
48 end-of-file
49 scp -q $tmp.cmd pcpqa@$host:$tmp.cmd
50 ssh -q pcpqa@$host /bin/sh $tmp.cmd >/dev/null 2>&1
51 ssh -q pcpqa@$host "rm -f $tmp.cmd"
54 _speak_to_me()
56 host=$1
57 pid=''
58 base=''
59 cat <<'End-of-File' | ssh -q pcpqa@$host sh >$tmp.tmp 2>$tmp.err
60 if [ -r $PCP_DIR/etc/pcp.env ]
61 then
62 . $PCP_DIR/etc/pcp.env
63 else
64 echo "Error: unable to read $PCP_DIR/etc/pcp.env!" >&2
65 exit 1
67 sudo rm -rf /tmp/$$ /tmp/$$.*
68 echo "log mandatory on once { hinv.ncpu }" >/tmp/$$.config
69 echo >>/tmp/$$.config
70 echo "[access]" >>/tmp/$$.config
71 echo "allow * : all;" >>/tmp/$$.config
72 test -k $PCP_TMP_DIR/pmlogger || sudo chmod o+w $PCP_TMP_DIR/pmlogger
73 ( pmlogger -L -c /tmp/$$.config -l /tmp/$$.log /tmp/$$ </dev/null >/dev/null 2>&1 ) &
74 echo pid=$! base=$$
75 End-of-File
77 echo >>$seq.full
78 echo "stdout from ssh to $host ..." >>$seq.full
79 cat $tmp.tmp >>$seq.full
80 echo >>$seq.full
81 echo "stderr from ssh to $host ..." >>$seq.full
82 cat $tmp.err >>$seq.full
84 eval `cat $tmp.tmp`
86 if [ -z "$pid" ]
87 then
88 echo "Arrgh ... failed to get remote pmlogger pid for host $host"
89 exit
92 if [ -z "$base" ]
93 then
94 echo "Arrgh ... failed to get remote archive basename for host $host"
95 exit
98 for i in 1 2 3 4 5 6 7 8 9 10
100 ( echo ; echo "iteration $i" ) >>$seq.full
101 if echo quit | pmlc -h $host $pid 2>&1 | tee -a $seq.full | grep 'Connected to' >/dev/null
102 then
103 break
104 else
105 if [ $i = 10 ]
106 then
107 echo "Arrgh ... pmlogger (pid=$pid) on host $host failed to start after 20 seconds"
108 ssh -q pcpqa@$host "ps | grep $pid"
109 ssh -q pcpqa@$host "ls -l /tmp/$base.*"
110 ssh -q pcpqa@$host "cat /tmp/$base.log"
111 exit 1
114 sleep 2
115 done
117 # the success cases
119 cat <<End-of-File | pmlc 2>&1 | _filter
120 connect $pid@$host
121 status
122 new volume
123 status
124 flush
125 # singular, all instances
126 query { pmcd.simabi pmcd.control.register }
127 # some instances
128 query pmcd.agent.type ["sample" "pmcd" "sampledso"]
129 # non-leaf
130 query pmcd.pdu_in
131 # logging
132 log mandatory on once pmcd.agent.type ["sample" "pmcd"]
133 End-of-File
135 # stopping and starting again should be enough to allow pmlogger
136 # to have logged the metrics from the last request ... except the
137 # pmlc control port socket may not have been ripped down, so
138 # sleep some
140 sleep 2
142 echo "after first pmlc session ..." >>$seq.full
143 ssh -q pcpqa@$host "ps | grep $pid" >>$seq.full 2>&1
144 ssh -q pcpqa@$host "ls -l /tmp/$base.*" >>$seq.full 2>&1
145 ssh -q pcpqa@$host "cat /tmp/$base.log" >>$seq.full 2>&1
147 cat <<End-of-File | pmlc 2>&1 | _filter
148 connect $pid@$host
149 log mandatory off pmcd.agent.type ["sampledso"]
150 query pmcd.agent.type ["sample" "pmcd" "sampledso"]
151 End-of-File
153 echo "after second pmlc session ..." >>$seq.full
154 ssh -q pcpqa@$host "ps | grep $pid" >>$seq.full 2>&1
155 ssh -q pcpqa@$host "ls -l /tmp/$base.*" >>$seq.full 2>&1
156 ssh -q pcpqa@$host "cat /tmp/$base.log" >>$seq.full 2>&1
158 # the failures
160 # echo "log mandatory on once proc" | pmlc -h $host $pid -D1
161 echo "connect 0@$host" | pmlc 2>&1 | _filter
163 # cleanup
165 if [ ! -z "$host" ]
166 then
167 _remote_signal $host $pid $base
168 pid=''
169 base=''
173 _cleanup()
175 if $need_clean
176 then
177 if [ ! -z "$pid" -a ! -z "$base" -a ! -z "$host" ]
178 then
179 _remote_signal $host $pid $base
180 pid=''
181 base=''
183 need_clean=false
185 rm -f $tmp.*
188 need_clean=true
189 status=1 # failure is the default!
190 trap "_cleanup; exit \$status" 0 1 2 3 15
192 host=''
193 pid=''
194 base=''
196 # the v1 host may be on the other side of the planet
198 PMCD_CONNECT_TIMEOUT=30
199 PMCD_REQUEST_TIMEOUT=30
200 export PMCD_CONNECT_TIMEOUT PMCD_REQUEST_TIMEOUT
202 # real QA test starts here
204 type="-v pcp>=2"
205 echo
206 echo "=== pmlogger host type: $type ==="
207 host=`./getpmcdhosts -L -n 1 $type`
208 if [ -z "$host" ]
209 then
210 echo "./getpmcdhosts failed to find a suitable host" >$seq.notrun
211 exit
212 else
213 echo "$type => $host" >>$seq.full
214 _speak_to_me $host
217 # output version depends on the PCP version at the _remote_ host
218 # not the local host as is normally the case
220 REMOTE_VER=`pmprobe -v -h $host pmcd.version \
221 | sed -e 's/"$//' -e 's/.*"//' \
222 | $PCP_AWK_PROG -F. '{printf "%02d%02d%02d\n",$1,$2,$3}'`
223 echo "host=$host REMOTE_VER=$REMOTE_VER" >>$seq.full
225 # success, all done
226 status=0
227 exit