3 # check the new behaviour of pmlogger_daily to collect archives
4 # from longer ago than just yesterday. Based on qa/532.
6 # Copyright (c) 2004 Silicon Graphics, Inc. All Rights Reserved.
10 echo "QA output created by $seq"
12 # get standard filters
17 # This test is not stable in the vicinity of a timezone change, e.g.
18 # daylight saving or summer time transitions.
19 # Don't run if this happened in the last 6 days.
22 now_hr_6
=`pmdate -6d '%H'`
23 if [ "$now_hr" != "$now_hr_6" ]
25 _notrun
"timezone change? now = ${now_hr}H:??M, 6 days ago = ${now_hr_6}H:??M"
36 -e "s/local:/HOST/g" \
37 -e "s/localhost/HOST/g" \
38 -e "s/`hostname`/HOST/g" \
39 -e "s/`hostname | sed -e 's/\..*//'`/HOST/g" \
40 -e '/\/var\/adm\/pcplog\/NOTICES/d' \
41 -e 's/-rw-r--r--\./-rw-r--r--/' \
43 /-rw-r--r--/ { print $1,"...",$5,"...",$9; next }
45 | _filter_cron_scripts
48 status
=1 # failure is the default!
49 trap "cd $here; $sudo rm -rf $tmp $tmp.*; $sudo mv $PCP_LOG_DIR/NOTICES.$$ $PCP_LOG_DIR/NOTICES; exit \$status" 0 1 2 3 15
51 # take explicit control of the umask
55 $sudo mv $PCP_LOG_DIR/NOTICES
$PCP_LOG_DIR/NOTICES.$$
61 # real QA test starts here
64 # unmerged archives for these days ...
70 [ $day -gt 0 -a $hour -gt 1 ] && continue
71 # aiming for the time to be hour:10, hour:20 and hour:30 on
72 # each day, even if that is ahead of NOW for today
75 hr_set
=`expr $hour - $now_hr`
76 [ "$hr_set" -ge 0 ] && hr_set
="+$hr_set"
78 min_set10
=`expr 10 - $now_min`
79 [ "$min_set10" -ge 0 ] && min_set10
="+$min_set10"
80 min_set20
=`expr 20 - $now_min`
81 [ "$min_set20" -ge 0 ] && min_set20
="+$min_set20"
82 min_set30
=`expr 30 - $now_min`
83 [ "$min_set30" -ge 0 ] && min_set30
="+$min_set30"
84 namea
=`pmdate -${day}d ${hr_set}H ${min_set10}M %Y%m%d.%H.%M`
85 nameb
=`pmdate -${day}d ${hr_set}H ${min_set20}M %Y%m%d.%H.%M`
86 namec
=`pmdate -${day}d ${hr_set}H ${min_set30}M %Y%m%d.%H.%M`
87 stampa
=`echo $namea | sed -e 's/\.//g'`
88 stampb
=`echo $nameb | sed -e 's/\.//g'`
89 stampc
=`echo $namec | sed -e 's/\.//g'`
92 echo "s/$namea/TODAY-$day.${hour}H.MM/g" >>$tmp/sed
93 echo "s/$nameb/TODAY-$day.${hour}H.MM-00/g" >>$tmp/sed
94 echo "s/$namec/TODAY-$day.${hour}H.MM-01/g" >>$tmp/sed
96 for ext
in 0 index meta
100 cp archives
/arch_a.
$ext $tmp/$namea.
$ext
101 touch -t $stampa $tmp/$namea.
$ext
103 cp archives
/arch_b.
$ext $tmp/$nameb.
$ext
104 touch -t $stampb $tmp/$nameb.
$ext
105 cp archives
/arch_b.
$ext $tmp/$namec.
$ext
106 touch -t $stampc $tmp/$namec.
$ext
109 echo "s/`pmdate -${day}d ${hr_set}H ${min_set10}M %Y%m%d`/TODAY-$day/g" >>$tmp/sed
112 # merged archives for these days ...
116 # aiming for the time to be 00:10 like when cron does its stuff
120 min_set
=`expr 10 - $now_min`
121 [ "$min_set" -ge 0 ] && min_set
="+$min_set"
122 namea
=`pmdate -${day}d ${hr_set}H ${min_set}M %Y%m%d`
123 stampa
=`echo $namea | sed -e 's/\.//g'`0010
124 echo "s/$namea/TODAY-$day/g" >>$tmp/sed
126 for ext
in 0 index meta
128 cp archives
/arch_a.
$ext $tmp/$namea.
$ext
129 touch -t $stampa $tmp/$namea.
$ext
131 echo "s/$namea/TODAY-$day/g" >>$tmp/sed
134 echo "s/TODAY-0/TODAY/g" >>$tmp/sed
135 echo "s/`pmdate %Y%m%d`/TODAY/g" >>$tmp/sed
137 ( cd $tmp; tar cf
- *.0 *.meta
*.index
2>/dev
/null
) \
138 |
( cd $tmp/foo
; tar xpf
- 2>/dev
/null
)
140 echo >$tmp/control
'$version=1.1
141 LOCALHOSTNAME n n '"$tmp"' ./config'
145 ls $tmp |
sed -f $tmp/sed | LC_COLLATE
=POSIX
sort |
tee $tmp.before
146 echo "sed ..." >>$seq.full
147 cat $tmp/sed >>$seq.full
148 echo "before ..." >>$seq.full
149 ls -l $tmp >>$seq.full
151 # list of culled files is in directory order, hence the cut and sort
152 # complexity at the end of this pipeline
155 echo "pmlogger_daily -k 4 -V ..." >>$seq.full
156 $sudo $PCP_BINADM_DIR/pmlogger_daily
-c $tmp/control
-k 4 -V -l $tmp.log
161 state == 0 { print >"'$tmp.out
.0'"
162 if ($0 ~ /older than 4 days/) state = 1
165 state == 1 && NF == 0 { state = 2 }
166 state == 1 { for (i = 1; i <= NF; i++) print $i >"'$tmp.out
.1'" }'
167 [ -f $tmp.out
.0 ] && cat $tmp.out
.0
168 [ -f $tmp.out
.1 ] && LC_COLLATE
=POSIX
sort $tmp.out
.1
170 echo "out.0 ..." >>$seq.full
171 [ -f $tmp.out
.0 ] && cat $tmp.out
.0 >>$seq.full
172 echo "out.1 ..." >>$seq.full
173 [ -f $tmp.out
.1 ] && cat $tmp.out
.1 >>$seq.full
177 ls $tmp |
sed -f $tmp/sed | LC_COLLATE
=POSIX
sort |
tee $tmp.after
178 echo "after ..." >>$seq.full
179 ls -l $tmp >>$seq.full
182 echo "Differences ..."
183 diff $tmp.before
$tmp.after