File: 895

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 (187 lines) | stat: -rwxr-xr-x 4,247 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
#!/bin/sh
# PCP QA Test No. 895
# pmlogger SIGINT badness
#
# https://github.com/performancecopilot/pcp/issues/116
#
# Copyright (c) 2016 Ken McDonell.  All Rights Reserved.
#

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

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

status=1	# failure is the default!
trap "cd $here; $sudo rm -rf $tmp $tmp.*; exit \$status" 0 1 2 3 15

cat <<End-of-File >$tmp.config
log mandatory on 100 msec {
    containers
    disk
    event
    filesys
    hinv
    ipc
    kernel
    mmv
    pmcd
    pmda
    quota
    rpc
    swap
    swapdev
    sysfs
    tmpfs
    vfs
}
End-of-File

# some of these metrics are not available on some platforms ...
#
case $PCP_PLATFORM
in
    linux)
	;;

    darwin)
	sed <$tmp.config >$tmp.tmp \
	    -e '/ containers$/d' \
	    -e '/ quota$/d' \
	    -e '/ ipc$/d' \
	    -e '/ swap$/d' \
	    -e '/ swapdev$/d' \
	    -e '/ sysfs$/d' \
	    -e '/ tmpfs$/d' \
	    -e '/ vfs$/d' \
	# end
	mv $tmp.tmp $tmp.config
	;;

    freebsd)
	sed <$tmp.config >$tmp.tmp \
	    -e '/ containers$/d' \
	    -e '/ filesys$/d' \
	    -e '/ quota$/d' \
	    -e '/ ipc$/d' \
	    -e '/ rpc$/d' \
	    -e '/ swapdev$/d' \
	    -e '/ sysfs$/d' \
	    -e '/ tmpfs$/d' \
	    -e '/ vfs$/d' \
	# end
	mv $tmp.tmp $tmp.config
	;;

    openbsd)
	sed <$tmp.config >$tmp.tmp \
	    -e '/ ipc$/d' \
	    -e '/ quota$/d' \
	    -e '/ rpc$/d' \
	    -e '/ swapdev$/d' \
	    -e '/ sysfs$/d' \
	    -e '/ tmpfs$/d' \
	    -e '/ vfs$/d' \
	# end
	mv $tmp.tmp $tmp.config
	;;

    solaris)
	sed <$tmp.config >$tmp.tmp \
	    -e '/ filesys$/d' \
	    -e '/ ipc$/d' \
	    -e '/ quota$/d' \
	    -e '/ rpc$/d' \
	    -e '/ swap$/d' \
	    -e '/ swapdev$/d' \
	    -e '/ sysfs$/d' \
	    -e '/ tmpfs$/d' \
	    -e '/ vfs$/d' \
	# end
	mv $tmp.tmp $tmp.config
	;;

    *)
	echo "Arrgh ... need test customization for $PCP_PLATFORM"
	exit
	;;
esac

_filter()
{
    cat \
    | tee -a $seq_full \
    | sed \
	-e '/re-established connection/d' \
	-e '/pduread: .* Interrupted system call/d' \
	-e '/Validating metrics/d' \
	-e '/^Fetch task/d' \
	-e '/^  Fetch group/d' \
	-e '/^Log for pmlogger /s/ on .*/ .../' \
	-e '/^preprocessor cmd:/s/: .*/: .../' \
	-e '/^Starting logger/s/".*/.../' \
	-e '/} logged every/s/: .*/: .../' \
	-e "s@$tmp@TMP@" \
	-e 's/[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]/DATE/' \
	-e 's/DATE [0-9][0-9][0-9][0-9]/DATE/' \
	-e 's/pmlogger([0-9][0-9]*)/pmlogger(PID)/' \
    | $PCP_AWK_PROG '
BEGIN			{ state = 0 }
$1 == "Group"		{ print "Group ... {"; state = 1; next }
state == 1 && $1 == "}"	{ print "	..."; state = 0 }
state == 0		{ print }'
}

# real QA test starts here
PCP_DERIVED_CONFIG=; export PCP_DERIVED_CONFIG
pmlogger -Doptfetch -h localhost -r -c $tmp.config -m qa_$seq -l $tmp.log $tmp &
pid=$!

pmsleep 6
kill -INT $pid
wait

_filter <$tmp.log

N=`grep '^  Fetch group' $tmp.log | tee -a $seq_full | wc -l | sed -e 's/ //g'`

# pmlogger ends up using N fetch groups 
# without timeouts, expect 6000msec * N fetch groups / 100msec = 60*N records
# +2 for preamble and postscript records
#
# So the upper bound is 61*N records.
#
# On really slow VMs we struggle to keep up with the number of metrics and
# the 100msec sampling rate, so 30*N is the lower bound ... this is OK,
# because if pmlogger is going to behave badly we'll miss the 60*N target
# by a mile!
#
max_nrec=`expr $N \* 61 + 2`
min_nrec=`expr \( $N \) \* 30 + 2`
echo "N(fetch groups)=$N max_nrec=$max_nrec min_nrec=$min_nrec" >>$seq_full
nrec=`pmdumplog $tmp | grep '^[0-9]' | grep -v '<mark>' | wc -l | sed -e 's/ //g'`
echo "nrec=$nrec log records" >>$seq_full
echo "log record frequency by fetch group size ..." >>$seq_full
pmdumplog $tmp \
| grep '^[0-9]' \
| grep -v '<mark>' \
| sed -e 's/^[^ ][^ ]* //' \
| sort \
| uniq -c \
| sed -e 's/\([0-9]\) \([0-9]\)/\1 x \2/' >>$seq_full

if [ "$nrec" -ge $min_nrec -a "$nrec" -le $max_nrec ]
then
    echo "OK, found expected number of archive records"
else
    echo "oops, $nrec archive records not between the expected range of $min_nrec and $max_nrec"
    pmdumplog $tmp | grep '^[0-9]' | grep -v '<mark>' >>$seq_full
fi

# success, all done
status=0

exit