pmrep: fix archive end time reporting
[pcp.git] / qa / 543
blob380db095e54f51011057cd18ab44f57bef3e7af7
1 #! /bin/sh
2 # PCP QA Test No. 543
3 # exercises the -m option to pmlogger_daily
5 # Note: this test will fail in the few days after a daylight savings
6 # change as the sample NOTICES file is not quite right
8 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
11 seq=`basename $0`
12 echo "QA output created by $seq"
14 # get standard environment, filters and checks
15 . ./common.product
16 . ./common.filter
17 . ./common.check
19 # This test is not stable in the vicinity of a timezone change, e.g.
20 # daylight saving or summer time transitions.
21 # Don't run if this happened in the last 1 day.
23 now_hr=`pmdate '%H'`
24 now_hr_1=`pmdate -1d '%H'`
25 if [ "$now_hr" != "$now_hr_1" ]
26 then
27 _notrun "timezone change? now = ${now_hr}H:??M, yesterday = ${now_hr_1}H:??M"
28 # NOTREACHED
31 host=`hostname`
32 NOTICES=$PCP_LOG_DIR/NOTICES
33 MAIL=/var/mail/pcpqa
34 HOME=`$PCP_AWK_PROG -F: '/^pcpqa/ { print $6 }' /etc/passwd`
35 FORWARD="$HOME/.forward"
37 smtp_port=25
38 echo quit | $PCP_BINADM_DIR/telnet-probe localhost $smtp_port \
39 || _notrun "Noone listening on smtp port $smtp_port"
41 _cleanup()
43 # put stuff we moved back in place
44 [ -f $tmp.notices ] && $sudo mv $tmp.notices $NOTICES
45 [ -f $tmp.mail ] && $sudo mv $tmp.mail $MAIL
46 [ -f $tmp.forward ] && $sudo mv $tmp.forward $FORWARD
47 rm -f $tmp.*
50 _filter()
52 sed -e 's/[A-Z][a-z][a-z] [A-Z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]$/DATESTAMP/' \
53 -e 's/^[0-9][0-9]:[0-9][0-9]/TIME/' \
54 -e "s,$PCP_RC_DIR,\$PCP_RC_DIR,"
57 status=1 # failure is the default!
58 trap "_cleanup; exit \$status" 0 1 2 3 15
59 rm -f $seq.full
61 # create a fake NOTICES file containing time-boundary entries
63 twodaysago=`pmdate -2d '%a %b %e %T %Z %Y'`
64 earlyyesterday=`pmdate -1d '%a %b %e %T %Y'`
65 timenow=`pmdate '%a %b %e %T %Y'`
66 oneminago=`pmdate -1M '%H:%M'`
67 intwomins=`pmdate +5M '%H:%M'`
68 infourmins=`pmdate +6M '%H:%M'`
70 # expect to get none from two days ago, 2 of 3 from yesterday,
71 # and all (1) from today
73 cat >$tmp.new <<EOF
74 Started by pmlogger_daily: $twodaysago
75 09:38 stop pmcd from $PCP_RC_DIR/pcp
76 11:54 start pmcd from $PCP_RC_DIR/pcp
78 DATE: $earlyyesterday
79 $oneminago stop pmcd from $PCP_RC_DIR/pcp
80 $intwomins start pmcd from $PCP_RC_DIR/pcp
81 $infourmins pmie: busy disk spindle 49.4:dks0d1@rattle
83 DATE: $timenow
84 $oneminago stop pmcd from $PCP_RC_DIR/pcp
85 EOF
87 # real QA test starts here
88 $sudo mv $NOTICES $tmp.notices
89 [ -f $MAIL ] && $sudo mv $MAIL $tmp.mail
90 [ -f $FORWARD ] && $sudo mv $FORWARD $tmp.forward
91 cp /dev/null $tmp.noconf
92 $sudo cp $tmp.new $NOTICES
93 cp $NOTICES $seq.full
94 echo >>$seq.full
95 $sudo $PCP_BINADM_DIR/pmlogger_daily -c $tmp.noconf -m pcpqa@$host
97 sleep 2 # let mail arrive (shouldn't take long)
99 # see what we got ...
100 cat $PCP_LOG_DIR/NOTICES.daily | tee -a $seq.full | _filter
102 # success, all done
103 status=0
104 exit