pmrep: update TODO, man page
[pcp.git] / qa / 151
blob1780b12b3883e649cc0d5ced0d002281ddecd0c5
1 #! /bin/sh
2 # PCP QA Test No. 151
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.
7 #
9 seq=`basename $0`
10 echo "QA output created by $seq"
12 # get standard filters
13 . ./common.product
14 . ./common.filter
15 . ./common.check
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.
21 now_hr=`pmdate '%H'`
22 now_hr_6=`pmdate -6d '%H'`
23 if [ "$now_hr" != "$now_hr_6" ]
24 then
25 _notrun "timezone change? now = ${now_hr}H:??M, 6 days ago = ${now_hr_6}H:??M"
26 # NOTREACHED
30 _filter()
32 tee -a $seq.full \
33 | sed -f $tmp/sed \
34 | sed \
35 -e "s;$tmp;TMP;g" \
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--/' \
42 | $PCP_AWK_PROG '
43 /-rw-r--r--/ { print $1,"...",$5,"...",$9; next }
44 { print }' \
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
53 umask 022
55 $sudo mv $PCP_LOG_DIR/NOTICES $PCP_LOG_DIR/NOTICES.$$
56 rm -f $seq.full
57 rm -rf $tmp $tmp.*
58 mkdir $tmp
59 mkdir $tmp/foo
61 # real QA test starts here
63 echo >$tmp/sed
64 # unmerged archives for these days ...
66 for day in 0 1 2 3
68 for hour in 1 4 16
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
74 now_hr=`pmdate %H`
75 hr_set=`expr $hour - $now_hr`
76 [ "$hr_set" -ge 0 ] && hr_set="+$hr_set"
77 now_min=`pmdate %M`
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'`
90 nameb=${namea}-00
91 namec=${namea}-01
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
98 if [ $hour -ne 4 ]
99 then
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
107 done
108 done
109 echo "s/`pmdate -${day}d ${hr_set}H ${min_set10}M %Y%m%d`/TODAY-$day/g" >>$tmp/sed
110 done
112 # merged archives for these days ...
114 for day in 4 5 6
116 # aiming for the time to be 00:10 like when cron does its stuff
118 hr_set=-`pmdate %H`
119 now_min=`pmdate %M`
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
130 done
131 echo "s/$namea/TODAY-$day/g" >>$tmp/sed
132 done
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'
143 echo
144 echo "Before ..."
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
154 echo
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
157 $sudo cat $tmp.log \
158 | tee -a $tmp.full \
159 | _filter \
160 | $PCP_AWK_PROG '
161 state == 0 { print >"'$tmp.out.0'"
162 if ($0 ~ /older than 4 days/) state = 1
163 next
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
175 echo
176 echo "After ..."
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
181 echo
182 echo "Differences ..."
183 diff $tmp.before $tmp.after
185 # all done
186 status=0
187 exit