pmrep: update TODO, man page
[pcp.git] / qa / 983
blobbc0be65fd0c708f92bef1025583b90e05aeed9b4
1 #!/bin/sh
2 # PCP QA Test No. 983
3 # pmie via proxies
5 # Copyright (c) 2015 Red Hat
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 which socat >/dev/null 2>&1 || _notrun "socat binary not installed"
18 port2=55432 # just some random port
19 port1=55431 # just some random port
20 echo | $PCP_BINADM_DIR/telnet-probe localhost $port1 \
21 && _notrun "Someone already listening on port $port1"
22 echo | $PCP_BINADM_DIR/telnet-probe localhost $port2 \
23 && _notrun "Someone already listening on port $port2"
24 # (technically, this is a TOCTTOU race condition)
27 status=1 # failure is the default!
28 $sudo rm -rf $tmp.* $seq.full
30 signal=$PCP_BINADM_DIR/pmsignal
32 _cleanup() {
33 $sudo rm -f $tmp.*
34 [ -z "$pmcd_pid" ] || sudo $signal $pmcd_pid
35 [ -z "$socat_pid" ] || sudo $signal $socat_pid
36 $sudo $PCP_RC_DIR/pmcd restart | _filter_pcp_start
38 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # ditch timestamps and exact hostnames
42 _filter_pmie() {
43 hostname=`hostname`
44 _filter_pmie_log |
45 sed -e 's/^\[.*\]/[TIMESTAMP]/' |
46 sed -e 's/'$hostname'/HOSTNAME/'
51 # real QA test starts here
53 # We use socat to create a loopback proxy for pmcd on some oddball
54 # port, and have pmie be forced to talk to it there. The idea is that
55 # if pmie were to still use the host-name as a pmNewContext attempt,
56 # it will fail (since there won't be a pmcd there).
58 # see also qa/283 for "pmcd -p" testing.
59 $sudo $PCP_RC_DIR/pmcd stop >/dev/null 2>&1
60 # allow time to cleanup and close all sockets
61 sleep 3
63 rm -f $seq.full
66 echo "=== starting pmcd on port $port1 ===" |tee -a $seq.full
67 cat >$tmp.sh <<END
68 #!/bin/sh
69 PATH=$PATH
70 $PCP_PMCD_PROG -f -l $tmp.log -p $port1 &
71 echo \$!
72 END
74 # Filter the stderr of this using a temp file
75 pmcd_pid=`$sudo sh $tmp.sh 2>$tmp.tmp`
76 cat $tmp.tmp 1>&2
77 sleep 1
80 echo "=== starting socat on port $port2 ===" |tee -a $seq.full
82 # Filter the stderr of this using a temp file
83 socat -d -d TCP-LISTEN:$port2,fork TCP:localhost:$port1 2>$tmp.socat &
84 socat_pid=$!
85 sleep 1
87 cat >$tmp.pmie <<END
88 delta = 1sec;
89 (sample.load > 40) -> print "found the meaning of %h %c %v";
90 END
93 for port in $port2 $port1 44321 # the latter will fail
95 echo "=== running pmie via $port ===" |tee -a $seq.full
96 pmie -f -h localhost:$port -c $tmp.pmie -T 5s > $tmp.out 2>&1
97 cat $tmp.out >> $seq.full
98 cat $tmp.out | _filter_pmie
99 #(echo f $tmp.pmie; echo l; echo r 5s) | pmie -d -f -h localhost:$port | _filter_pmie
100 done
103 # collect misc.
104 echo "pmie log" >> $seq.full
105 cat $tmp.log >> $seq.full
106 echo "socat log" >> $seq.full
107 cat $tmp.socat >> $seq.full
109 # success, all done
110 status=0
112 exit