blob: b2667ecf044df117e5c015ac6d8d6d3ff1632534 (
plain)
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
|
#! /bin/sh
# PCP QA Test No. 185
# pmnewlog config save/restore checks
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
#
seq=`basename $0`
echo "QA output created by $seq"
# create our own tmpdir to ensure we can write to it
tmpdir=/tmp/$seq-$$
rm -rf $tmpdir
mkdir -p $tmpdir/pmlogger
export PCP_TMP_DIR=$tmpdir
# get standard filters
. ./common.product
. ./common.filter
tmp=$tmpdir/$$
signal=$PCP_BINADM_DIR/pmsignal
trap "$signal -a pmlogger >/dev/null 2>&1; cd; rm -rf $tmpdir; exit" 0 1 2 3 15
_filter_dumplog()
{
sed \
-e '/^[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9][0-9][0-9]/s//TIMESTAMP/' \
-e 's/^\(log started *\).*/\1DATESTAMP/' \
-e 's/^\(last log entry *\).*/\1DATESTAMP/' \
-e 's/^\(current time *\).*/\1DATESTAMP/' \
-e 's/^\( *commencing *\).*/\1DATESTAMP/' \
-e 's/^\( *ending *\).*/\1DATESTAMP/' \
-e '/^Performance metrics/s/host .*/host HOST/'
}
_filter_newlog()
{
sed \
-e 's/pid [0-9][0-9]*/pid PID/' \
-e '/ \/usr\/pcp\/bin\/pmlogger /s/.*/-- ps line removed --/' \
-e '/^\/usr\/pcp\/bin\/pmlogger/s/[0-9][0-9]*/PID/g' \
-e '/configuration file saved as/s/[0-9][0-9]*/PID/g' \
-e 's/\[[0-9][0-9]*]/[PID]/' \
-e 's/ host [^ ]*/ host HOST/g' \
-e '/^Getting logged/s/host HOST/host name/' \
-e 's/ -h [^ ]*/ -h HOST/g' \
-e 's/ SIG.* done/ signal stuff ... done/' \
-e '/Error \[<stdin>,/d' \
-e '/Warning \[<stdin>,/d' \
-e '/Not connected to any/d' \
-e '/Logging statement ignored/d' \
-e '/Problem with lookup for metric/d' \
-e '/Reason: Unknown metric name/d' \
-e '/Try again. Information not currently available/d' \
-e '/Unknown or illegal metric identifier/d' \
-e '/Metric not supported by this version/d' \
-e '/^log size/s/[0-9][0-9]*/BYTES/' \
-e '/^Contacting pmlogger /d' \
-e '/^pmnewlog: Warning: errors from talking /d' \
-e '/^continuing .../d' \
-e '/New pmlogger configuration file saved /d' \
-e '/^[ ]*$/d'
}
# real QA test starts here
cat <<End-of-File >$tmp.config
# singular instances
log mandatory off sample.control
log mandatory on 10 sec sample.load
log advisory on once sample.seconds
# multiple instances
log mandatory off sample.colour
log mandatory on 20 sec sample.bin
log advisory on 1 min sample.bucket
End-of-File
rm -f $tmp.arch.*
pmlogger -L -c $tmp.config -l $tmp.log $tmp.arch &
pid=$!
sleep 1
echo
echo "=== pmnewlog #1 =="
rm -f $tmp.arch.1.*
# ps $PCP_PS_ALL_FLAGS | grep pmlogger
# echo "pid=$pid"
pmnewlog -C $tmp.config.1 -p $pid $tmp.arch.1 2>&1 >$tmp.out
_filter_newlog <$tmp.out | _filter_dumplog >$tmp.check
if [ -s $tmp.check ]
then
echo "Unexpected output!"
echo
echo "Filtered residual ..."
cat $tmp.check
echo
echo "Unfiltered output from pmnewlog ..."
cat $tmp.out
else
echo "Nothing unexpected in the pmnewlog output"
fi
echo
echo "=== config differences ==="
diff $tmp.config $tmp.config.1
echo
echo "=== pmnewlog #2 =="
rm -f $tmp.arch.2.*
hostname=`hostname`
pid=`ps $PCP_PS_ALL_FLAGS \
| tee $tmp.ps \
| grep -v grep \
| $PCP_AWK_PROG "/pmlogger.*-h $hostname.*-c \/tmp\// "'{print $2}'`
# ps $PCP_PS_ALL_FLAGS | grep pmlogger
# echo "pid=$pid"
if [ "X$pid" = X ]
then
echo "Error: no pid matching \"pmlogger.*-h `hostname`.*-c /tmp/\" from ps!"
cat $tmp.ps
exit 1
fi
pmnewlog -C $tmp.config.2 -p $pid $tmp.arch.2 2>&1 >$tmp.out
_filter_newlog <$tmp.out | _filter_dumplog >$tmp.check
if [ -s $tmp.check ]
then
echo "Unexpected output!"
echo
echo "Filtered residual ..."
cat $tmp.check
echo
echo "Unfiltered output from pmnewlog ..."
cat $tmp.out
else
echo "Nothing unexpected in the pmnewlog output"
fi
echo
echo "=== config differences (expect none!) ==="
diff $tmp.config.1 $tmp.config.2
|