File: 503

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 (240 lines) | stat: -rwxr-xr-x 7,654 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/bin/sh
# PCP QA Test No. 503
# Test pmlogrewrite use with pmlogger_daily
#
# Copyright (c) 2011 Ken McDonell.  All Rights Reserved.
#
# check-group-include: pmlogextract
#

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

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

PMLOGREWRITE=`which pmlogrewrite 2>/dev/null`
[ -n "$PMLOGREWRITE" ] || _notrun "pmlogrewrite not installed"

NEEDREWRITE=$PCP_LOG_DIR/pmlogger/.NeedRewrite

_cleanup()
{
    cd $here
    $sudo rm -rf $tmp.*
    [ -f $NEEDREWRITE.$seq ] && $sudo mv $NEEDREWRITE.$seq $NEEDREWRITE
}

status=0	# success is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15

[ -f $NEEDREWRITE ] && $sudo mv $NEEDREWRITE $NEEDREWRITE.$seq

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 '/^Roll .*\/NOTICES/d' \
	-e '/^Start .*\/NOTICES/d' \
	-e '/^Start \[/s/ 2[0-9:. -]*/ DATESTAMP/' \
	-e '/^End \[/s/ 2[0-9:. -]*/ DATESTAMP /' \
	-e '/^Add merge callback for: pmlogger_daily_report/d' \
	-e '/^Merge callbacks .../d' \
	-e '/^callback: .*pmlogger_daily_report/d' \
	-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()
{
    $sudo rm -f $tmp.arch/*
    sudo pmlogcp archives/rewrite $tmp.arch/20111001.21.10
    sudo pmlogcp archives/rewrite $tmp.arch/20111001.22.10
    echo "global { time -> +1:00:00 }" >$tmp.conf.time
    $sudo $PMLOGREWRITE -c $tmp.conf.time -i $tmp.arch/20111001.22.10

    # pmlogger_daily runs as the user "pcp" ... fix ownership
    #
    find $tmp.arch/* -type f | xargs -r $sudo chown $PCP_USER:$PCP_GROUP
    find $tmp.arch/* -type d | xargs -r $sudo chown $PCP_USER:$PCP_GROUP
    $sudo touch $tmp.log
    $sudo chown $PCP_USER:$PCP_GROUP $tmp.log
}

_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 -dilmst $1 \
    | tee -a $seq_full \
    | sed -e '/^\[[0-9][0-9]* bytes]/d' >$tmp.in

    pmdumplog -z -dilmst $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
$sudo chown $PCP_USER:$PCP_GROUP $tmp.arch

# metrics in play from archives/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
# need to be a place the user $PCP_USER can cd to from pmlogger_daily
#
cd /var/tmp
$sudo -u $PCP_USER -g $PCP_GROUP sh -c "umask 022; $PCP_BINADM_DIR/pmlogger_daily -P -D -c $tmp.control -x never -V -l $tmp.log"
cd $here
$sudo cat $tmp.log | _filter
mkdir $tmp.ok
$sudo 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
    $sudo $PMLOGREWRITE -c $tmp.conf -i $tmp.arch/20111001.22.10
    cd /var/tmp
    $sudo -u $PCP_USER -g $PCP_GROUP sh -c "umask 022; $PCP_BINADM_DIR/pmlogger_daily -P -D -c $tmp.control -x never -V -l $tmp.log"
    cd $here
    $sudo cat $tmp.log | _filter

    echo | tee -a $seq_full
    echo "+++ expect fix via local config file +++" | tee -a $seq_full
    _setup
    $sudo $PMLOGREWRITE -c $tmp.conf -i $tmp.arch/20111001.22.10
    $sudo cp $tmp.conf $tmp.arch/pmlogrewrite
    cd /var/tmp
    $sudo -u $PCP_USER -g $PCP_GROUP sh -c "umask 022; $PCP_BINADM_DIR/pmlogger_daily -P -D -c $tmp.control -x never -V -l $tmp.log"
    cd $here
    $sudo cat $tmp.log | _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
    $sudo $PMLOGREWRITE -c $tmp.conf -i $tmp.arch/20111001.22.10
    $sudo ln -s $tmp.conf $tmp.arch/pmlogrewrite
    cd /var/tmp
    $sudo -u $PCP_USER -g $PCP_GROUP sh -c "umask 022; $PCP_BINADM_DIR/pmlogger_daily -P -D -c $tmp.control -x never -V -l $tmp.log"
    cd $here
    $sudo cat $tmp.log | _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
    $sudo $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
    cd /var/tmp
    $sudo -u $PCP_USER -g $PCP_GROUP sh -c "umask 022; $PCP_BINADM_DIR/pmlogger_daily -P -D -c $tmp.control -x never -V -l $tmp.log"
    cd $here
    $sudo cat $tmp.log | _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
    $sudo $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 ln -s $PCP_VAR_DIR/config/pmlogrewrite $tmp.arch/pmlogrewrite
    cd /var/tmp
    $sudo -u $PCP_USER -g $PCP_GROUP sh -c "umask 022; $PCP_BINADM_DIR/pmlogger_daily -P -D -c $tmp.control -x never -V -l $tmp.log"
    cd $here
    $sudo cat $tmp.log | _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
$sudo $PMLOGREWRITE -c $tmp.conf -i $tmp.arch/20111001.22.10
$sudo cp $tmp.conf $tmp.arch/pmlogrewrite
cd /var/tmp
$sudo -u $PCP_USER -g $PCP_GROUP sh -c "umask 022; $PCP_BINADM_DIR/pmlogger_daily -P -D -r -c $tmp.control -x never -V -l $tmp.log"
cd $here
$sudo cat $tmp.log | _filter

# success, all done
exit