File: 322

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (250 lines) | stat: -rwxr-xr-x 6,281 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#! /bin/sh
# PCP QA Test No. 322
# pmlogger (assorted) and pmlc (PCP 2.0) version compatibility
# any host version ... see 374 for 64-bit host version
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard filters
. ./common.product
. ./common.filter
. ./common.check


# based on version 2 or 3 archive remotely ($1)
#
_filter()
{
    tee -a $seq_full \
    | _filter_pmdumplog \
    | sed \
	-e '/^pmlogger .* on host .* is logging metrics from host .*/d' \
	-e '/^PMCD host/d' \
	-e '/^log started/d' \
    | $PCP_AWK_PROG '
BEGIN				{ if ("'"$1"'" >= 3) labelsize=808
				  else labelsize=132
				}
/datax/				{ skip = 3 }
skip > 0			{ skip--; next }
$1 == "log" && $2 == "size"	{ if ($3 == labelsize) $3 = "[label]"
				  else if ($3 > labelsize) $3 = "[label] plus some"
				}
				{ print }'
}

_remote_signal()
{
    host="$1"
    pid="$2"
    base="$3"

    cat <<end-of-file >$tmp.cmd
. \$PCP_DIR/etc/pcp.env
sudo -u \$PCP_USER \$PCP_BINADM_DIR/pmsignal -s TERM $pid $base
sleep 1
sudo -u \$PCP_USER \$PCP_BINADM_DIR/pmsignal -s KILL $pid $base
sudo rm -f /tmp/$base.*
end-of-file
    scp -q $tmp.cmd pcpqa@$host:$tmp.cmd
    ssh -q pcpqa@$host /bin/sh $tmp.cmd >/dev/null 2>&1
    ssh -q pcpqa@$host "rm -f $tmp.cmd"
}

_speak_to_me()
{
    host=$1
    pid=''
    base=''
    cat <<End-of-File | ssh -q pcpqa@$host sh >$tmp.tmp 2>$tmp.err
if [ -r \$PCP_DIR/etc/pcp.env ]
then
    . \$PCP_DIR/etc/pcp.env
else
    echo "Error: unable to read \$PCP_DIR/etc/pcp.env!" >&2
    exit 1
fi
sudo rm -rf /tmp/\$$ /tmp/\$$.*
echo "# config for qa/$seq from `hostname` on `date`" >/tmp/\$$.config
echo "log mandatory on once { hinv.ncpu }" >>/tmp/\$$.config
echo >>/tmp/\$$.config
echo "[access]" >>/tmp/\$$.config
echo "allow * : all;" >>/tmp/\$$.config
( sudo -u \$PCP_USER pmlogger -L -c /tmp/\$$.config -l /tmp/\$$.log /tmp/\$$ </dev/null >/dev/null 2>&1 ) &
sleep 2
pid=\`sed -n </tmp/\$$.log -e '/Info: Start/{
s/.*(//
s/).*//
p
}'\`
echo pid=\$pid base=\$\$
End-of-File

    echo >>$seq_full
    echo "stdout from ssh to $host ..." >>$seq_full
    cat $tmp.tmp >>$seq_full
    echo >>$seq_full
    echo "stderr from ssh to $host ..." >>$seq_full
    cat $tmp.err >>$seq_full

    eval `cat $tmp.tmp`

    if [ -z "$base" ]
    then
	echo "Arrgh ... failed to get remote archive basename for host $host"
	exit
    fi

    if [ -z "$pid" ]
    then
	echo "Arrgh ... failed to get remote pmlogger pid for host $host"
	ssh -q pcpqa@$host "cat /tmp/$base.log"
	exit
    fi

    eval `ssh -q pcpqa@$host grep PCP_ARCHIVE_VERSION /etc/pcp.conf`
    echo "$host: PCP_ARCHIVE_VERSION=$PCP_ARCHIVE_VERSION" >>$seq_full

    for i in 1 2 3 4 5 6 7 8 9 10
    do
	( echo ; echo "iteration $i" ) >>$seq_full
	if echo quit | pmlc -h $host $pid 2>&1 | tee -a $seq_full | grep 'Connected to' >/dev/null
	then
	    break
	else
	    if [ $i = 10 ]
	    then
		echo "Arrgh ... pmlogger (pid=$pid) on host $host failed to start after 20 seconds"
		ssh -q pcpqa@$host "ps -ef | grep -E '$pid|pmlogger'"
		ssh -q pcpqa@$host "ls -l /tmp/$base.*"
		ssh -q pcpqa@$host "cat /tmp/$base.log"
		ssh -q pcpqa@$host pmdumplog -dilmst /tmp/$base
		ssh -q pcpqa@$host "ls -l $PCP_TMP_DIR/pmlogger"
		exit 1
	    fi
	fi
	sleep 2
    done

    # the success cases
    #
    cat <<End-of-File | pmlc 2>&1 | _filter $PCP_ARCHIVE_VERSION
connect $pid@$host
status
new volume
status
flush
# singular, all instances
query { pmcd.simabi pmcd.control.register }
# some instances
query pmcd.agent.type ["sample" "pmcd" "sampledso"]
# non-leaf
query pmcd.pdu_in
# logging
log mandatory on once pmcd.agent.type ["sample" "pmcd"]
End-of-File

    # stopping and starting again should be enough to allow pmlogger
    # to have logged the metrics from the last request ... except the
    # pmlc control port socket may not have been ripped down, so
    # sleep some
    #
    sleep 2

    echo "after first pmlc session ..." >>$seq_full
    ssh -q pcpqa@$host "ps | grep $pid" >>$seq_full 2>&1
    ssh -q pcpqa@$host "ls -l /tmp/$base.*" >>$seq_full 2>&1
    ssh -q pcpqa@$host "cat /tmp/$base.log" >>$seq_full 2>&1

    cat <<End-of-File | pmlc 2>&1 | _filter $PCP_ARCHIVE_VERSION
connect $pid@$host
log mandatory off pmcd.agent.type ["sampledso"]
query pmcd.agent.type ["sample" "pmcd" "sampledso"]
End-of-File

    echo "after second pmlc session ..." >>$seq_full
    ssh -q pcpqa@$host "ps | grep $pid" >>$seq_full 2>&1
    ssh -q pcpqa@$host "ls -l /tmp/$base.*" >>$seq_full 2>&1
    ssh -q pcpqa@$host "cat /tmp/$base.log" >>$seq_full 2>&1

    # the failures
    #
    echo "connect 0@$host" | pmlc 2>&1 | _filter $PCP_ARCHIVE_VERSION

    # cleanup
    #
    if [ ! -z "$host" ]
    then
	_remote_signal $host $pid $base
	pid=''
	base=''
    fi
}

_cleanup()
{
    if $need_clean
    then
	if [ ! -z "$pid" -a ! -z "$base" -a ! -z "$host" ]
	then
	    _remote_signal $host $pid $base
	    pid=''
	    base=''
	fi
	need_clean=false
    fi
    rm -f $tmp.*
    $sudo rm -rf /tmp/\$$ /tmp/\$$.*
}

need_clean=true
status=1	# failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15

host=''
pid=''
base=''

# the v1 host may be on the other side of the planet
#
PMCD_CONNECT_TIMEOUT=30
PMCD_REQUEST_TIMEOUT=30
export PMCD_CONNECT_TIMEOUT PMCD_REQUEST_TIMEOUT

# real QA test starts here

# strickly speaking need a remote host runnun pcp>=2, but with old
# PCP 2.7.8 and PCP 4.0.0 hosts in the QA farm, we might pick one of
# them, and there are fewer metrics below pmcd.pdu_in in the PMNS,
# which causes slightly different output for the
#	query pmcd.pdu_in
# below ... so best to avoid that.
#
type="-v pcp>=5.3.5"
echo
echo "=== pmlogger host type: $type ==="
host=`./getpmcdhosts -P -L -n 1 $type`
if [ -z "$host" ]
then
    _notrun "./getpmcdhosts failed to find a suitable host"
    # NOTREACHED
else
    echo "$type => $host" >>$seq_full
    _speak_to_me $host
fi

# output version depends on the PCP version at the _remote_ host
# not the local host as is normally the case
#
REMOTE_VER=`pmprobe -v -h $host pmcd.version \
    | sed -e 's/"$//' -e 's/.*"//' \
    | $PCP_AWK_PROG -F. '{printf "%02d%02d%02d\n",$1,$2,$3}'`
echo "host=$host REMOTE_VER=$REMOTE_VER" >>$seq_full

# success, all done
status=0
exit