File: 381

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 (222 lines) | stat: -rwxr-xr-x 5,095 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
#! /bin/sh
# PCP QA Test No. 381
# pmlc with new -p port and "connect port <n>" options
#
# 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

rem_host=`./getpmcdhosts -L -n 1 -P -a sample 2>$tmp.tmp`
if [ -z "$rem_host" ]
then
    msg=`cat $tmp.tmp`
    rm -f $tmp.tmp
    _notrun "$msg"
    # NOTREACHED
fi
rm -f $tmp.tmp

_filter()
{
    sed \
	-e '/Performance Co-Pilot Logger/,/ <instance> /d' \
	-e '/^PMCD host/d' \
	-e "s/ $pid / QA-PMLOGGER-PID /" \
	-e "s/\[$pid\]/[QA-PMLOGGER-PID]/" \
	-e "s/_logger_id=$pid/_logger_id=QA-PMLOGGER-PID/" \
	-e 's/connect [0-9][0-9]* /connect PID /' \
	-e "s/\[[0-9][0-9]*\]/[PMLOGGER-PID]/" \
	-e "s/_logger_id=[0-9][0-9]*/_logger_id=PMLOGGER-PID/" \
	-e "s/$rem_host/REMOTE-HOST/" \
	-e "s/$myhost/LOCAL-HOST/" \
	-e "s/local:/LOCAL-HOST/" \
	-e "s/port $port /port PORT /" \
	-e 's/logging metrics from host .*/logging metrics from host .../' \
	-e '/^log started/d' \
	-e '/^last log entry/d' \
	-e '/^current time/d' \
	-e '/^log volume/d' \
	-e '/^log size/s/.*/... status output .../'
}

# _speak_to_me <host> <pid> [<port>]
#
_speak_to_me()
{
    echo
    # default
    _port=$port
    [ -n "$3" ] && _port="$3"
    echo "=== _host=$1 _logger_id=$2 ===" >$tmp.out
    echo >>$seq_full
    echo "=== _host=$1 _logger_id=$2 _port=$_port ===" >>$seq_full
    if [ -z "$1" ]
    then
	pminfo -f pmcd.pmlogger.port >>$seq_full 2>&1
    else
	pminfo -h `echo $1 | sed -e 's/@//'` -f pmcd.pmlogger.port >>$seq_full 2>&1
    fi
    # allow pmlogger socket to be closed and ready to accept()
    #
    sleep 2
    cat <<End-of-File | pmlc $DEBUG -ei >>$tmp.out 2>&1
connect primary $1
status
query sample.drift
disconnect
connect port $_port $1
status
flush
disconnect
connect $2 $1
status
flush
End-of-File
    cat $tmp.out >>$seq_full
    _filter <$tmp.out \
    | sed -e "s/port $_port/port PORT/g"
}

_ping()
{
    echo "Remote host: $rem_host [pid: $rem_pid port: $rem_port]" >>$seq_full
    pminfo -f -h $rem_host pmcd.pmlogger.port >>$seq_full 2>&1
    ssh $rem_host '. /etc/pcp.env; $PCP_PS_PROG $PCP_PS_ALL_FLAGS' 2>&1 \
    | grep -E '[P]PID|/[p]mlogger( |$)' >>$seq_full
    echo >>$seq_full
    echo "Local host: $myhost [pid: $pid port: $port]" >>$seq_full
    pminfo -f -h $myhost pmcd.pmlogger.port >>$seq_full 2>&1
    $PCP_PS_PROG $PCP_PS_ALL_FLAGS \
    | grep -E '[P]PID|/[p]mlogger( |$)' >>$seq_full
}

_cleanup()
{
    if $need_clean
    then
	if [ ! -z "$pid" ]
	then
	    $sudo $signal -s TERM $pid
	    sleep 1
	    pid=''
	    cat $tmp.log >>$seq_full
	fi
	echo
	if [ -f $tmp.log ]
	then
	    _filter_pmlogger_log <$tmp.log
	else
	    echo "Warning: $tmp.log missing"
	fi
	echo
	_service pmcd restart 2>&1 | _filter_pcp_restart
	_wait_for_pmcd
	_service pmlogger restart 2>&1 | _filter_pcp_restart
	_wait_for_pmlogger
	need_clean=false
    fi
    $sudo rm -f $tmp.*
    exit
}

need_clean=true
signal=$PCP_BINADM_DIR/pmsignal
status=1	# failure is the default!
DEBUG=''
trap "_cleanup; exit \$status" 0 1 2 3 15

myhost=`hostname`
pid=''

# force one pmResult into the archive to trigger log label
# and preamble writing
#
echo "log mandatory on once sampledso.long.ten" >$tmp.config

_start_up_pmlogger -h $rem_host -L -c $tmp.config -l $tmp.log $tmp >/dev/null 2>&1
_wait_for_pmlogger $pid $tmp.log || _exit 1

pminfo -f -h $rem_host pmcd.pmlogger.port >$tmp.tmp
rem_port=`cat $tmp.tmp | sed -n -e '/"primary"/{
s/.*value *//
p
q
}'`
if [ -z "$rem_port" ]
then
    cat $tmp.tmp
    echo "Error: cannot find port for remote primary logger!"
    exit
fi

rem_pid=`cat $tmp.tmp | sed -n -e '/"primary"/d' -e '/ value '$rem_port' *$/{
s/.* "//
s/".*//p
}'`
if [ -z "$rem_pid" ]
then
    cat $tmp.tmp
    echo "Error: cannot find pid for remote primary logger on port $rem_port!"
    exit
fi

port=`pminfo -f pmcd.pmlogger.port \
      | sed -n -e '/"primary"/d' -e '/\['$pid' /{
s/.* value //p
}'`

echo "=== ping @ start ===" >>$seq_full
_ping

# real QA test starts here

_speak_to_me "" $pid
_speak_to_me "" "port $port"

_speak_to_me @$myhost $pid
_speak_to_me @$myhost "port $port"

_speak_to_me @$rem_host $rem_pid $rem_port

# make sure the primary logger is terminated and stop pmcd
#
prim_pid=`$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep '/[p]mlogger' | grep ' -P' | $PCP_AWK_PROG '{ print $2 }'`
if [ ! -z "$prim_pid" ]
then
    $sudo $signal -s TERM $prim_pid
    _wait_pmlogger_end $prim_pid || _exit 1
else
    echo "Eh? primary pmlogger not running?"
    _ping
fi
if ! _service pmlogger stop 2>&1; then _exit 1; fi \
| _filter_pcp_stop
_wait_pmlogger_end || _exit 1
if ! _service pmcd stop 2>&1; then _exit 1; fi \
| _filter_pcp_stop
_wait_pmcd_end || _exit 1

echo >>$seq_full
echo "=== ping after stopping local pcp and pmcd  ===" >>$seq_full
_ping

echo
_speak_to_me "" $pid
_speak_to_me "" "port $port"
#debug# DEBUG="-D all"
_speak_to_me @$rem_host $rem_pid $rem_port

echo >>$seq_full
echo "=== ping @ end ===" >>$seq_full
_ping

# success, all done
status=0
exit