3 # pmlogger_daily ... do you work at all?
5 # NEW VERSION for YYYYDDMM style naming convention (see also 530)
7 # NOTE - THIS TEST WILL FAIL IF RUN IN THE FIRST 5 MINUTES AFTER
8 # MIDNIGHT - c'est la vie, I'm afraid.
10 # Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
14 echo "QA output created by $seq"
16 # get standard environment, filters and checks
21 # This test is not stable in the vicinity of a timezone change, e.g.
22 # daylight saving or summer time transitions.
23 # Don't run if this happened in the last 2 days.
26 now_hr_2
=`pmdate -2d '%H'`
27 if [ "$now_hr" != "$now_hr_2" ]
29 _notrun
"timezone change? now = ${now_hr}H:??M, 2 days ago = ${now_hr_2}H:??M"
35 if fmt --help 2>&1 |
grep '.-w, ' >/dev
/null
38 # -w, --width=WIDTH maximum line width (default of 75 columns)
40 elif fmt --help 2>&1 |
grep '.-w .* width' >/dev
/null
43 # -w <n> set maximum width to <n>
45 elif fmt --help 2>&1 |
grep '.-w width' >/dev
/null
50 elif fmt --help 2>&1 |
grep '.-m ' >/dev
/null
52 # NetBSD's version of fmt is different (may apply to other variants) ...
55 echo "Warning: no clue how to set max line length for fmt(1)"
60 BEGIN { cmd = "'"`echo $cmd`"'" }
61 /^Archive files older than/ { eatlines=1; longone=" "; print; next }
62 eatlines { if ( match ($0, "^ ") ) {
63 for ( i=1; i <=NF; i++ ) {
64 longone = sprintf ("%s %s",longone,$i)
69 longone = ""; eatlines = 0
74 END { if ( eatlines ) {
83 -e "s/`hostname`/HOST/g" \
84 -e "s/localhost/HOST/g" \
85 -e "s/local:/HOST/g" \
86 -e "s/`hostname | sed -e 's/\..*//'`/HOST/g" \
87 -e '/\/var\/adm\/pcplog\/NOTICES/d' \
88 -e 's/-rw-r--r--\./-rw-r--r--/' \
90 /-rw-r--r--/ { print $1,"...",$5,"...",$9; next }
92 | _filter_cron_scripts
100 $sudo mv $PCP_LOG_DIR/NOTICES.$$
$PCP_LOG_DIR/NOTICES
103 status
=1 # failure is the default!
104 trap "_cleanup; exit \$status" 0 1 2 3 15
105 $sudo rm -rf $tmp $tmp.
*
107 # take explicit control of the umask
110 $sudo mv $PCP_LOG_DIR/NOTICES
$PCP_LOG_DIR/NOTICES.$$
114 # real QA test starts here
119 for day
in 0 1 2 3 4 5
122 # aiming for the time to be 00:02 and 00:04 on each day,
123 # even if that is ahead of NOW for today
128 min2
=`expr 2 - $now_min`
129 [ "$min2" -ge 0 ] && min2
="+$min2"
130 min4
=`expr 4 - $now_min`
131 [ "$min4" -ge 0 ] && min4
="+$min4"
132 namea
=`pmdate -${day}d ${hour}H ${min2}M $fmt.%H.%M`
133 nameb
=`pmdate -${day}d ${hour}H ${min4}M $fmt.%H.%M`
134 yesterday
=`pmdate -1d ${hour}H ${min2}M $fmt`
135 stampa
=`echo $namea | sed -e 's/\.//g'`
136 stampb
=`echo $nameb | sed -e 's/\.//g'`
137 echo "s/$namea/NOW-$day.00.02/g" >>$tmp/sed
138 echo "s/$nameb/NOW-$day.00.04/g" >>$tmp/sed
140 for ext
in 0 index meta
142 cp archives
/arch_a.
$ext $tmp/$namea.
$ext
143 touch -t $stampa $tmp/$namea.
$ext
144 cp archives
/arch_b.
$ext $tmp/$nameb.
$ext
145 touch -t $stampb $tmp/$nameb.
$ext
148 echo "s/NOW-0/TODAY/g" >>$tmp/sed
149 echo "s/NOW-1/YESTERDAY/g" >>$tmp/sed
150 echo "s/`pmdate %Y%m%d`/TODAY/g" >>$tmp/sed
151 echo "s/$yesterday/YESTERDAY/g" >>$tmp/sed
153 echo >$tmp/control
'$version=1.1
154 LOCALHOSTNAME n n '"$tmp"' ./config'
156 cat $tmp/sed >>$seq.full
160 echo "=== [${verbose+verbose}] regular show ==="
161 echo "=== [${verbose+verbose}] regular show ===" >>$seq.full
162 $sudo $PCP_BINADM_DIR/pmlogger_daily
-o -c $tmp/control
-k 3 $verbose -l $tmp.log
164 $sudo cat $tmp.log | _filter
165 ls -lt $tmp >>$seq.full
166 ls $tmp |
sed -f $tmp/sed |
tee -a $seq.full | LC_COLLATE
=POSIX
sort
169 echo "=== [${verbose+verbose}] nothing to do but cull some more ==="
170 echo "=== [${verbose+verbose}] nothing to do but cull some more ===" >>$seq.full
171 for ext
in 0 index meta
173 mv $tmp/$yesterday.
$ext $tmp/save.
$ext
175 $sudo $PCP_BINADM_DIR/pmlogger_daily
-o -c $tmp/control
-k 2 $verbose -l $tmp.log
176 $sudo cat $tmp.log | _filter
177 ls -lt $tmp >>$seq.full
178 ls $tmp |
sed -f $tmp/sed |
tee -a $seq.full | LC_COLLATE
=POSIX
sort
181 echo "=== [${verbose+verbose}] error, output already exists ==="
182 echo "=== [${verbose+verbose}] error, output already exists ===" >>$seq.full
183 for ext
in 0 index meta
185 cp archives
/arch_a.
$ext $tmp/$yesterday.17.18.
$ext
186 mv $tmp/save.
$ext $tmp/$yesterday.
$ext
188 $sudo $PCP_BINADM_DIR/pmlogger_daily
-o -c $tmp/control
-k 2 $verbose -l $tmp.log
189 $sudo cat $tmp.log | _filter
190 ls -lt $tmp >>$seq.full
191 ls $tmp |
sed -f $tmp/sed |
tee -a $seq.full | LC_COLLATE
=POSIX
sort