blob: c08fe4297b3802f164798cf992f0d6370262a07c (
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
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
|
#!/bin/sh
# PCP QA Test No. 503
# Test pmlogrewrite use with pmlogger_daily
#
# Copyright (c) 2011 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
which pmlogrewrite >/dev/null 2>&1 || _notrun "pmlogrewrite not installed"
status=0 # success is the default!
$sudo rm -rf $tmp.* $seq.full
trap "$sudo rm -rf $tmp.*; exit \$status" 0 1 2 3 15
hostname=`hostname | sed -e 's/\..*//'`
_filter()
{
tee -a $seq.full \
| sed \
-e "s/for host $hostname/for host HOSTNAME/g" \
-e "s/for host localhost/for host HOSTNAME/g" \
-e "s/for host localhost\.localdomain/for host HOSTNAME/g" \
-e "s/for host local:/for host HOSTNAME/g" \
-e "s/for host \"localhost\"/for host \"HOSTNAME\"/g" \
-e "s/for host \"localhost\.localdomain\"/for host \"HOSTNAME\"/g" \
-e "s/for host \"local:\"/for host \"HOSTNAME\"/g" \
-e "s/for host \"$hostname\"/for host \"HOSTNAME\"/g" \
-e "s;$tmp;TMP;g" \
-e "s/^\([+-][+-][+-] TMP\...t*\).*/\1/" \
-e '/^-rw-r--r--/s/-rw-r--r--.* 2011/-rw-r--r-- ... 2011/' \
-e `echo $PCP_LOG_DIR | sed -e 's/\//\\\\\//g'`'\/NOTICES/d'
}
_setup()
{
rm -f $tmp.arch/*
for x in 0 meta index
do
cp src/rewrite.$x $tmp.arch/20111001.21.10.$x
cp src/rewrite.$x $tmp.arch/20111001.22.10.$x
done
echo "global { time -> +1:00:00 }" >$tmp.conf.time
pmlogrewrite -c $tmp.conf.time -i $tmp.arch/20111001.22.10
}
_cmp()
{
ok=true
for ext in 0 index meta
do
if [ ! -f "$1.$ext" ]
then
echo "Arrgh ... $1.$ext missing" | _filter
ok=false
fi
if [ ! -f "$2.$ext" ]
then
echo "Warning: $2.$ext missing" | _filter
ok=false
fi
done
$ok || return
pmdumplog -z -a $1 \
| tee -a $seq.full \
| sed -e '/^\[[0-9][0-9]* bytes]/d' >$tmp.in
pmdumplog -z -a $2 \
| tee -a $seq.full \
| sed -e '/^\[[0-9][0-9]* bytes]/d' >$tmp.out
diff -u $tmp.in $tmp.out | _filter
}
# take explicit control of the umask
#
umask 022
mkdir $tmp.arch
# metrics in play from src/rewrite archive
#
# sample.bin PMID: 29.0.6
# Data Type: 32-bit int InDom: 29.2 0x7400002
# Semantics: instant Units: none
# inst [100 or "bin-100"] value 100
# inst [200 or "bin-200"] value 200
# inst [300 or "bin-300"] value 300
# inst [400 or "bin-400"] value 400
# inst [500 or "bin-500"] value 500
# inst [600 or "bin-600"] value 600
# inst [700 or "bin-700"] value 700
# inst [800 or "bin-800"] value 800
# inst [900 or "bin-900"] value 900
#
# sampledso.double.hundred PMID: 30.0.27
# Data Type: double InDom: PM_INDOM_NULL 0xffffffff
# Semantics: instant Units: none
# value 100
#
# Log Label (Log Format Version 2)
# Performance metrics from host bozo-laptop
# commencing Sat Oct 1 21:10:11.751 2011
# ending Sat Oct 1 21:10:12.128 2011
# Archive timezone: EST-10
#
cat <<End-of-File >$tmp.control
\$version=1.1
LOCALHOSTNAME n n $tmp.arch -c $tmp.pmlogger
End-of-File
cat <<End-of-File >$tmp.pmlogger
log mandatory on once { sample.bin }
End-of-File
# real QA test starts here
echo "+++ should just work ... +++" | tee -a $seq.full
_setup
$sudo $PCP_BINADM_DIR/pmlogger_daily -c $tmp.control -V 2>&1 | _filter
mkdir $tmp.ok
mv $tmp.arch/20111001.* $tmp.ok
cat <<'End-of-File' | while read conf
global { hostname -> dreaming }
metric sampledso.double.hundred { type -> float }
End-of-File
do
echo "$conf" >$tmp.conf
echo | tee -a $seq.full
echo "!!! $conf !!!" | tee -a $seq.full
echo | tee -a $seq.full
echo "+++ expect mismatch +++" | tee -a $seq.full
_setup
pmlogrewrite -c $tmp.conf -i $tmp.arch/20111001.22.10
$sudo $PCP_BINADM_DIR/pmlogger_daily -c $tmp.control -V 2>&1 | _filter
echo | tee -a $seq.full
echo "+++ expect fix via local config file +++" | tee -a $seq.full
_setup
pmlogrewrite -c $tmp.conf -i $tmp.arch/20111001.22.10
cp $tmp.conf $tmp.arch/pmlogrewrite
$sudo $PCP_BINADM_DIR/pmlogger_daily -c $tmp.control -V 2>&1 | _filter
_cmp $tmp.ok/20111001 $tmp.arch/20111001
echo | tee -a $seq.full
echo "+++ expect fix via local symlink config file +++" | tee -a $seq.full
_setup
pmlogrewrite -c $tmp.conf -i $tmp.arch/20111001.22.10
ln -s $tmp.conf $tmp.arch/pmlogrewrite
$sudo $PCP_BINADM_DIR/pmlogger_daily -c $tmp.control -V 2>&1 | _filter
_cmp $tmp.ok/20111001 $tmp.arch/20111001
echo | tee -a $seq.full
echo "+++ expect fix via global config dir +++" | tee -a $seq.full
_setup
pmlogrewrite -c $tmp.conf -i $tmp.arch/20111001.22.10
$sudo mkdir -p $PCP_VAR_DIR/config/pmlogrewrite
$sudo cp $tmp.conf $PCP_VAR_DIR/config/pmlogrewrite/qa.$seq
$sudo $PCP_BINADM_DIR/pmlogger_daily -c $tmp.control -V 2>&1 | _filter
_cmp $tmp.ok/20111001 $tmp.arch/20111001
$sudo rm -f $PCP_VAR_DIR/config/pmlogrewrite/qa.$seq
echo | tee -a $seq.full
echo "+++ expect fix via symlink to global config dir +++" | tee -a $seq.full
_setup
pmlogrewrite -c $tmp.conf -i $tmp.arch/20111001.22.10
$sudo mkdir -p $PCP_VAR_DIR/config/pmlogrewrite
$sudo cp $tmp.conf $PCP_VAR_DIR/config/pmlogrewrite/qa.$seq
ln -s $PCP_VAR_DIR/config/pmlogrewrite $tmp.arch/pmlogrewrite
$sudo $PCP_BINADM_DIR/pmlogger_daily -c $tmp.control -V 2>&1 | _filter
_cmp $tmp.ok/20111001 $tmp.arch/20111001
$sudo rm -f $PCP_VAR_DIR/config/pmlogrewrite/qa.$seq
done
echo | tee -a $seq.full
echo "+++ expect fail when -r used and local config file present +++" | tee -a $seq.full
_setup
pmlogrewrite -c $tmp.conf -i $tmp.arch/20111001.22.10
cp $tmp.conf $tmp.arch/pmlogrewrite
$sudo $PCP_BINADM_DIR/pmlogger_daily -r -c $tmp.control -V 2>&1 | _filter
# success, all done
exit
|