File: 294

package info (click to toggle)
pcp 7.0.5-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,916 kB
  • sloc: ansic: 1,478,844; sh: 177,285; xml: 160,462; cpp: 83,809; python: 24,349; perl: 18,303; yacc: 6,877; lex: 2,864; makefile: 2,694; awk: 165; fortran: 60; java: 52
file content (221 lines) | stat: -rwxr-xr-x 6,069 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
#! /bin/sh
# PCP QA Test No. 294
# Basic pmproxy functionality
#
# See qa/1290 for valgrind version of this test.
#
# Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
#

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

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

which pmdumptext >/dev/null 2>&1 || _notrun "No installed pmdumptext binary"

#debug# tmp=`pwd`/tmp
signal=$PCP_BINADM_DIR/pmsignal
status=1	# failure is the default!
username=`id -u -n`
trap "_cleanup; $sudo rm -rf $tmp.*; exit \$status" 0 1 2 3 15

pmproxy_was_running=false
[ -f $PCP_RUN_DIR/pmproxy.pid ] && pmproxy_was_running=true
echo "pmproxy_was_running=$pmproxy_was_running" >>$seq_full

rm -f $seq.out
case $PCP_PLATFORM
in
    darwin)
	ln $seq.out.darwin $seq.out || exit 1
	;;
    *)
	ln $seq.out.default $seq.out || exit 1
	;;
esac

_cleanup()
{
    # kill off the pmproxy we started
    #
    $sudo $signal -a pmproxy >>$seq_full 2>&1

    if $pmproxy_was_running
    then
	echo "Restart pmproxy ..." >>$seq_full
	_service pmproxy restart >>$seq_full 2>&1
	_wait_for_pmproxy
    else
	echo "Stopping pmproxy ..." >>$seq_full
	_service pmproxy stop >>$seq_full 2>&1
    fi
}

# in addition to the ususal filtering tasks ..
# on slow VMs (like bozo-vm) we may need to dodge warnings
# from pmie's rule scheduler around pmcd reconnection ... the awk
# script at the end iof the pipeline does this.
#
_filter()
{
    sed \
	-e '/hinv/s/ [0-9][0-9]*$/ N/' \
	-e '/^[A-Z][a-z][a-z] [A-Z][a-z][a-z]  *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/{
# pmdumptext
s//DATE/
s/	[0-9][0-9.]*/	N/g
}' \
	-e '/^\[[A-Z][a-z][a-z] [A-Z][a-z][a-z]  *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9]]/{
# pmie trailer
s//[DATE]/
s/([0-9][0-9]*)/(PID)/
}' \
	-e '/expr_1/s/  *[0-9][0-9.]*/ N/g' \
	-e '/^@ [A-Z][a-z][a-z] [A-Z][a-z][a-z]  *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][[0-9][0-9][0-9]/{
# pmstat header1
s//@ DATE/
}' \
	-e '/^   1 min   swpd   free   buff  cache   pi   po   bi   bo   in   cs  us  sy  id/{
# pmstat header3
s//   1 min   swpd   free   buff  cache   si   so   bi   bo   in   cs  us  sy  id/
}' \
	-e '/[0-9?][0-9.Kmg]*  *[0-9?][0-9.Kmg]*  *[0-9?][0-9.Kmg]*  *[0-9?][0-9.Kmg]*  *[0-9?][0-9.Kmg]*/{
# pmstat data
s/  *?/ ?/g
s/  *[0-9][0-9.Kmg]*/ N/g
}' \
    | _filter_me \
    | $PCP_AWK_PROG '
skip == 1 && /^[^ ]/		{ skip = 0 }
/^run: schedule eval/		{ skip = 1 }
/^sleepTight: negative/		{ skip = 1 }
/^Last sleepTight until:/	{ skip = 1 }
/^This sleepTight\() entry:/	{ skip = 1 }
/^Harvest children done:/	{ skip = 1 }
/^Want sleepTight until:/	{ skip = 1 }
/Task dump @/			{ skip = 1 }
skip == 0			{ print }'

}

_filter_me()
{
    sed \
	-e "s/`hostname`/MY_HOSTNAME/g" \
	-e "s/`hostname | sed -e 's/\..*//'`/MY_HOSTNAME/" \
	-e "s/local:/MY_HOSTNAME/" \
	-e "s/localhost\.localdomain/MY_HOSTNAME/" \
	-e "s/localhost/MY_HOSTNAME/" \
	-e "s#$PCP_VAR_DIR#PCP_VAR_DIR#g" \
	-e "s#$PCP_SYSCONF_DIR/pmlogger/config.pmstat#TMP.logger.config#g" \
	-e "s,$tmp.config,TMP.logger.config,g" \
	-e "s#$tmp#TMP#g"
}

_filter_pmproxy()
{
    sed \
	-e '/^__pmSetSocketIPC: fd=/d' \
	-e '/^__pmSetDataIPC:/d' \
	-e '/^__pmDataIPC: /d' \
	-e '/^IPC table fd/d' \
	-e '/^pmproxy: disabled time series, requires libuv support (missing)/d' \
    # end
}

_do()
{
    echo
    echo "+++ $* +++" | tee -a $seq_full | _filter_me
    if which $1 >/dev/null 2>&1
    then
	eval $* 2>&1 | tee -a $seq_full | _filter
	connects=`grep AcceptNewClient $tmp.log | wc -l | sed -e 's/  *//g'`
	disconnects=`grep DeleteClient $tmp.log | wc -l | sed -e 's/  *//g'`
	difference=$(($connects - $disconnects))
	echo "N connects"
	echo "N-$difference disconnects"
    else
	echo "Skipped, no $1 binary installed"
    fi
}

_do_config()
{
    cat >$tmp.config <<End-of-File
log advisory on default {
    kernel.all.load
    swap.used
    mem.util.free
    mem.util.bufmem
    mem.bufmem
    mem.util.cached
    swap.in
    swap.pagesin
    swap.out
    swap.pagesout
    disk.all.blkread
    disk.all.blkwrite
    kernel.all.intr
    kernel.all.intr.non_vme
    kernel.all.pswitch
    kernel.all.cpu
}
End-of-File
}

$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep -E '[P]PID|/[p]mproxy( |$)' >>$seq_full
$sudo netstat -t -l -4 -p | grep '4432[23]' >>$seq_full
if ! _service pmproxy stop >/dev/null 2>&1; then _exit 1; fi
$sudo $signal -a pmproxy >/dev/null 2>&1
$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep -E '[P]PID|/[p]mproxy( |$)' >>$seq_full
# give any running pmproxy a chance to shutdown cleanly
#
sleep 2
$sudo netstat -t -l -4 -p | grep '4432[23]' >>$seq_full

mkdir -p $tmp.rundir
export PCP_RUN_DIR=$tmp.rundir
proxyargs="-Dcontext -U $username"
$PCP_BINADM_DIR/pmproxy $proxyargs -l $tmp.log 2>&1 | _filter_pmproxy
_wait_for_pmproxy || _exit 1
$sudo netstat -t -l -4 -p | grep '4432[23]' >>$seq_full

export PMPROXY_HOST=localhost
$PCP_BINADM_DIR/pmcd_wait -t 5sec -h localhost@localhost
$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep -E '[P]PID|/[p]mproxy( |$)' >>$seq_full
cat $tmp.log >> $seq_full

# real QA test starts here
_do pminfo -h $PMPROXY_HOST -d pmcd.agent
_do pminfo -h $PMPROXY_HOST -f sample.hordes
_do pmprobe -v -h localhost hinv.ncpu
_do pmval -h `hostname` -t 0.5 -s 3 sample.bin

echo "kernel.all.load;" >$tmp.in
_do pmie -h $PMPROXY_HOST -c $tmp.in -v -t 0.5 -T 1.75
echo "kernel.all.cpu.user :localhost;" >$tmp.in
_do pmie -h $PMPROXY_HOST -c $tmp.in -v -t 0.5 -T 1.75
_do pmdumptext -h `hostname` -t 0.5 -s 2 sample.string.hullo
_do pmdumptext -t 0.5 -s 2 localhost:sample.string.hullo
_do pmdumptext -t 0.5 -s 2 `hostname`:kernel.all.load

# Note: there used to be special casing for Darwin/Solaris platforms
# here.  This is wrong, pmstat must still run on these platforms and
# produce no values for some columns.

_do pmstat -h $PMPROXY_HOST -t 0.5 -s 2
_do_config
_do pmlogger -h localhost -c $tmp.config -t 0.5sec -s 6 -l $tmp.logger.log $tmp.arch
_do pmstat -S +1sec -t 0.5sec -s 1 -a $tmp.arch -z

( echo ""; echo "=== pmproxy.log ===" ) >>$seq_full
cat $tmp.log >>$seq_full

# success, all done
status=0
exit