File: 1108

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (152 lines) | stat: -rwxr-xr-x 4,251 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#! /bin/sh
# PCP QA Test No. 1108
# pv:821339 sed gives "Too many commands" in daily cron script
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
# Copyright (c) 2018 Red Hat. All Rights Reserved.
#
# check-group-exclude: pmlogger
# check-group-exclude: pmnewlog
# 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

# if the primary logger is configured for logpush, we need to
# quietly move on and not dink with things ...
#
if pminfo -f pmcd.pmlogger.archive 2>&1 \
   | tee -a $seq_full \
   | grep -q '"primary".*"http://'
then
    _notrun "primary pmlogger configured for logpush"
    # NOTREACHED
fi

NEEDREWRITE=$PCP_LOG_DIR/pmlogger/.NeedRewrite

_cleanup()
{
    # restore yesterday's files
    #
    cd $PCP_LOG_DIR/pmlogger
    for dir in */$seq
    do
	[ "$dir" = "*/$seq" ] && continue
	$sudo mv "$dir"/* $dir/..
	$sudo rmdir "$dir"
    done
    cd $here

    $sudo rm -f $tmp.*
    [ -f $NEEDREWRITE.$seq ] && $sudo mv $NEEDREWRITE.$seq $NEEDREWRITE
}

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

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

# don't need to regenerate config.default with pmlogconf
#
PMLOGGER_CHECK_SKIP_LOGCONF=yes; export PMLOGGER_CHECK_SKIP_LOGCONF

_filter()
{
    sed \
	-e "s;$PCP_BINADM_DIR/pmlogger;pmlogger;g" \
	-e '/mv .*\/NOTICES .*\/NOTICES.old/d' \
	-e '/touch .*\/NOTICES/d' \
	-e '/^+ date-and-timestamp /s/stamp .*/stamp .../' \
	-e '/^+ cd /s/cd .*/cd .../' \
	-e '/^+ mv /s/mv .*/mv .../' \
	-e '/^+ ln /d' \
	-e '/^+ pmlogger /s/pmlogger .*/pmlogger .../' \
	-e '/^+ pmnewlog /s/pmnewlog .*/pmnewlog .../' \
	-e '/^+ mkaf /s/mkaf .*/mkaf .../' \
	-e '/^+ rm /d' \
	-e '/^+ pmlogcompress /d' \
	-e '/^+ pmlogger_merge /d' \
	-e '/^[12][0-9][0-9][0-9][01][0-9][0-3][0-9]\.[0-9][0-9]\.[0-9][0-9]/d' \
	-e '/Warning: no write access/d' \
	-e 's/ *$//' \
	| tr -s ' '
}

echo "pmlogger processes at the beginning ..." >>$seq_full
$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep '[P]PID|/[p]mlogger( |$)' >>$seq_full

# Avoid conflict with normal management of the summary logs ...
# this is lifted from pmlogger_daily

# each summarized log is named yyyymmdd using yesterday's date
# previous day's logs are named yymmdd (old format) or
# yyyymmdd (new year 2000 format)
#
SUMMARY_LOGNAME=`pmdate -1d %Y%m%d`
echo "SUMMARY_LOGNAME=$SUMMARY_LOGNAME" >>$seq_full
echo "Files to be moved before we start ..." >>$seq_full
ls -l $PCP_LOG_DIR/pmlogger/*/$SUMMARY_LOGNAME* >>$seq_full 2>&1
# save yesterday's files
#
cd $PCP_LOG_DIR/pmlogger
for file in */$SUMMARY_LOGNAME*
do
    [ "$file" = "*/$SUMMARY_LOGNAME*" ] && continue
    dir=`dirname $file`
    [ ! -d "$dir/$seq" ] && $sudo mkdir "$dir/$seq"
    $sudo mv "$file" "$dir/$seq"
done
cd $here

# create a temporary control file with well-known contents, ensure
# we exercise a fix for rebuilding zero-length configuration files
$sudo rm -f $tmp.control
echo '$version=1.1' >> $tmp.control
echo "LOCALHOSTNAME y n PCP_LOG_DIR/pmlogger/LOCALHOSTNAME -c $tmp.conf" >> $tmp.control
touch $tmp.conf

# make sure pmlogger_daily gets a timestamp that is at least
# a minute after the previous primary logger was started to avoid
# the collision on the timestamp and the extra 3 mv's needed to
# rename the archive files from <timestamp> to <timestamp>-00
#
current=`pminfo -f pmcd.pmlogger.archive | sed -n -e '/"primary"/{
s;.*/;;
s/"//
p
}'`
if [ -z "$current" ]
then
    echo "Arrgh ... cannot get current primary pmlogger timestamp from"
    pminfo -f pmcd.pmlogger.archive
    ls -l $PCP_RUN_DIR/pmlogger*
    status=1
    exit
fi
echo "current=$current" >>$seq_full
sec=0
while [ $sec -lt 60 ]
do
    now=`pmdate %Y%m%d.%H.%M`
    [ "$now" != "$current" ] && break
    echo "now=$now" >>$seq_full
    sleep 1
    sec=`expr $sec + 1`
done
echo "done, now=$now" >>$seq_full

# real QA test starts here
# need to be a place the user $PCP_USER can cd to from pmlogger_daily
#
cd /var/tmp
$sudo -u $PCP_USER -g $PCP_GROUP sh -c "umask 022; $PCP_BINADM_DIR/pmlogger_daily -P -o -k 550 -N -c $tmp.control" 2>&1 \
| tee -a $seq_full \
| _filter
cd $here