File: 920

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 (158 lines) | stat: -rwxr-xr-x 4,092 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
153
154
155
156
157
158
#!/bin/sh
# PCP QA Test No. 920
# pmlogger_check with Martins Innus <minnus@buffalo.edu> style
# multi-level directory structure.
#
# Copyright (c) 2017 Ken McDonell.  All Rights Reserved.
#
# check-group-include: logutil
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

_check_job_scheduler

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

_cleanup()
{
    if $needclean
    then
	_service pmlogger stop 2>&1 | _filter_pcp_stop
	_restore_config $control
	if [ -f $PCP_SYSCONFIG_DIR/pmlogger_timers ]
	then
	    _restore_config $PCP_SYSCONFIG_DIR/pmlogger_timers
	fi
	needclean=false
	_service pmlogger start 2>&1 | _filter_pcp_start
	_wait_for_pmlogger
	_restore_job_scheduler $tmp.cron $tmp.systemd $sudo
    fi
    cd $here
    $sudo rm -rf $tmp $tmp.* $PCP_ARCHIVE_DIR/$seq
}

_report()
{
    # Note: some versions of ls(1), e.g. OS X, don't report directory
    # names from the command line (so no pmlogger: line below)
    #
    if [ ! -d $PCP_ARCHIVE_DIR/$seq ]
    then
	echo "Arrgh: directory $PCP_ARCHIVE_DIR/$seq not created"
	$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep -E '[P]PID|/[p]mlogger( |$)'
	return
    fi


    cd $PCP_ARCHIVE_DIR
    ls -lR $seq | tee -a $seq_full | $PCP_AWK_PROG '
NF < 4		{ print; next }
		{ print "mode=" $1 " user=" $3 " group=" $4 " name=" $NF }' \
    | sed \
	-e '/^total /d' \
	-e '/name=Latest/d' \
	-e '/name=lock/d' \
	-e 's/[2-9][0-9][0-9][0-9]:$/YYYY:/' \
	-e 's/[2-9][0-9][0-9][0-9]\/[01][0-9]:$/YYYY\/MM:/' \
	-e 's/[2-9][0-9][0-9][0-9]\/[01][0-9]\/[0-3][0-9]:$/YYYY\/MM\/DD:/' \
	-e 's/=[2-9][0-9][0-9][0-9]$/=YYYY/' \
	-e 's/=[0-3][0-9]$/=NN/' \
	-e 's/[2-9][0-9][0-9][0-9][01][0-9][0-3][0-9]/YYYYMMDD/' \
	-e 's/[012][0-9]\.[0-5][0-9]\./HH.MM./' \
	-e 's/\. user=/ user=/' \
    # end
    cd $here
}

_filter_pmlogger_check()
{
    sed \
	-e '/pmlogger_check.service/d' \
	-e '/pmlogger_check.timer/d' \
	-e '/pmlogger_check.path/d' \
    #end
}

control=$PCP_PMLOGGERCONTROL_PATH
[ -f $PCP_PMLOGGERCONTROL_PATH.d/local ] && \
control=$PCP_PMLOGGERCONTROL_PATH.d/local

PMLOGGER_CHECK_SKIP_LOGCONF=yes; export PMLOGGER_CHECK_SKIP_LOGCONF

# real QA test starts here
_remove_job_scheduler $tmp.cron $tmp.systemd $sudo

cat <<End-of-File >$tmp.control
# dummy file created by qa/$seq on `date`
# the goal here is to have a non-primary logger that has a deeply
# nested directory structure for the logs
\$version=1.1
LOCALHOSTNAME   n   n   PCP_ARCHIVE_DIR/$seq/myhost/2017/02/12 -c /dev/null -L -l $tmp.log.1
LOCALHOSTNAME	y   n	PCP_ARCHIVE_DIR/$seq/primary	-r -T24h10m -c config.default -v 100Mb -l $tmp.log.2
End-of-File
_save_config $control
$sudo cp $tmp.control $control

if [ -f $PCP_SYSCONFIG_DIR/pmlogger_timers ]
then
    cat <<End-of-File >$tmp.timers
# Installed by qa/$seq on `date`
# ... force -z for pmlogger_daily so no "reexec" thank you
#
PMLOGGER_DAILY_PARAMS=-z
End-of-File
    _save_config $PCP_SYSCONFIG_DIR/pmlogger_timers
    $sudo cp $tmp.timers $PCP_SYSCONFIG_DIR/pmlogger_timers
fi

if ! _service pmlogger restart; then _exit 1; fi \
| _filter_pcp_restart

# wait up to 20 seconds for our pmlogger to start
#
i=0
while [ $i -lt 20 ]
do
    if $PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep '/[p]mlogger.* -c /dev/null -L' >/dev/null
    then
	break
    fi
    sleep 1
    i=`expr $i + 1`
done

# pmlogger process has started, give it a chance to create the archive files
#
sleep 1

_report
echo

# wait for primary pmlogger ... our pmlogger may have got started first
# ... without this the _service stop in _cleanup() risks clobbering the
# previous start for the primary pmlogger before it is finished starting
# up, and this may lead to systemd complaints
#
_wait_for_pmlogger || _exit 1

# save pmlogger logs for triage
#
echo "=== pmlogger -c /dev/null -L" >>$seq_full
ls -lR $PCP_ARCHIVE_DIR/$seq/myhost/2017/02/12 >>$seq_full
cat $tmp.log.1 >>$seq_full
echo "=== pmlogger -c config.default" >>$seq_full
cat $tmp.log.2 >>$seq_full

# success, all done
status=0
exit