File: 543

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 (110 lines) | stat: -rwxr-xr-x 3,072 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
#! /bin/sh
# PCP QA Test No. 543
# exercises the -m option to pmlogger_daily
#
# Note: this test will fail in the few days after a daylight savings
#       change as the sample NOTICES file is not quite right
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  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

# This test is not stable in the vicinity of a timezone change, e.g.
# daylight saving or summer time transitions.
# Don't run if this happened in the last 1 day.
#
now_hr=`pmdate '%H'`
now_hr_1=`pmdate -1d '%H'`
if [ "$now_hr" != "$now_hr_1" ]
then
    _notrun "timezone change? now = ${now_hr}H:??M, yesterday = ${now_hr_1}H:??M"
    # NOTREACHED
fi

host=`hostname`
NOTICES=$PCP_LOG_DIR/NOTICES
MAIL=/var/mail/pcpqa
HOME=`$PCP_AWK_PROG -F: '/^pcpqa/ { print $6 }' /etc/passwd`
FORWARD="$HOME/.forward"

smtp_port=25
$PCP_BINADM_DIR/telnet-probe -c localhost $smtp_port \
	|| _notrun "Noone listening on smtp port $smtp_port"

NEEDREWRITE=$PCP_LOG_DIR/pmlogger/.NeedRewrite

_cleanup()
{
    # put stuff we moved back in place
    [ -f $tmp.notices ] && $sudo mv $tmp.notices $NOTICES
    [ -f $tmp.mail ] && $sudo mv $tmp.mail $MAIL
    [ -f $tmp.forward ] && $sudo mv $tmp.forward $FORWARD
    rm -f $tmp.*
    [ -f $NEEDREWRITE.$seq ] && $sudo mv $NEEDREWRITE.$seq $NEEDREWRITE
}

_filter()
{
    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/' \
	-e 's/^[0-9][0-9]:[0-9][0-9]/TIME/' \
        -e "s,$PCP_RC_DIR,\$PCP_RC_DIR,"
}

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

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

# create a fake NOTICES file containing time-boundary entries
# 
twodaysago=`pmdate -2d '%a %b %e %T %Z %Y'`
earlyyesterday=`pmdate -1d '%a %b %e %T %Y'`
timenow=`pmdate '%a %b %e %T %Y'`
oneminago=`pmdate -1M '%H:%M'`
intwomins=`pmdate +5M '%H:%M'`
infourmins=`pmdate +6M '%H:%M'`

# expect to get none from two days ago, 2 of 3 from yesterday,
# and all (1) from today
# 
cat >$tmp.new <<EOF
Started by pmlogger_daily: $twodaysago
09:38 stop pmcd from $PCP_RC_DIR/pmcd
11:54 start pmcd from $PCP_RC_DIR/pmcd

DATE: $earlyyesterday
$oneminago stop pmcd from $PCP_RC_DIR/pmcd
$intwomins start pmcd from $PCP_RC_DIR/pmcd
$infourmins pmie: busy disk spindle 49.4:dks0d1@rattle

DATE: $timenow
$oneminago stop pmcd from $PCP_RC_DIR/pmcd
EOF

# real QA test starts here
$sudo mv $NOTICES $tmp.notices
[ -f $MAIL ] && $sudo mv $MAIL $tmp.mail
[ -f $FORWARD ] && $sudo mv $FORWARD $tmp.forward
cp /dev/null $tmp.noconf
$sudo cp $tmp.new $NOTICES
cp $NOTICES $seq_full
echo >>$seq_full
$sudo -u $PCP_USER -g $PCP_GROUP $PCP_BINADM_DIR/pmlogger_daily -P -c $tmp.noconf -m pcpqa@$host

sleep 2	# let mail arrive (shouldn't take long)

# see what we got ...
cat $PCP_LOG_DIR/NOTICES.daily | tee -a $seq_full | _filter

# success, all done
status=0
exit