File: 1424

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 (147 lines) | stat: -rwxr-xr-x 3,863 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
#!/bin/sh
# PCP QA Test No. 1424
# Check out the pmlogger configuration style being used by Joe White
# at Center for Computational Research - University at Buffalo.
#
# Copyright (c) 2022 Ken McDonell.  All Rights Reserved.
#

if [ $# -eq 0 ]
then
    seq=`basename $0`
    echo "QA output created by $seq"
else
    # use $seq from caller, unless not set
    [ -n "$seq" ] || seq=`basename $0`
    echo "QA output created by `basename $0` $*"
fi

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

pmlogctl status 2>&1 | tee -a $seq_full >$tmp.tmp
nloggers=`sed -e 1d <$tmp.tmp | wc -l | sed -e 's/  *//g'`
rm -f $tmp.tmp
[ "$nloggers" -gt 1 ] && _notrun "more than one pmlogger already running"

# 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

_cleanup()
{
    cd $here
    _service pmlogger stop >>$seq_full 2>&1
    $sudo rm -f $PCP_ETC_DIR/pcp/pmlogger/control.d/$seq
    $sudo rm -rf $PCP_ARCHIVE_DIR/$seq
    sleep 1
    _service pmlogger start >>$seq_full 2>&1
    _wait_for_pmlogger
    $sudo rm -rf $tmp $tmp.*
}

status=0	# success is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
$sudo rm -rf $PCP_ARCHIVE_DIR/$seq

cat <<End-of-File >$tmp.control
# Installed by PCP QA test $seq on `date`
#

# DO NOT REMOVE OR EDIT THE FOLLOWING LINE
\$version=1.1

# for remote loggers running over a WAN with potentially long delays
\$PMCD_CONNECT_TIMEOUT=150
\$PMCD_REQUEST_TIMEOUT=120

\$PCP_COMPRESSAFTER=never

LOCALHOSTNAME            n   n        "PCP_ARCHIVE_DIR/$seq/\$(date +%Y)/\$(date +%m)/LOCALHOSTNAME/\$(date +%Y)-\$(date +%m)-\$(date +%d)"	-r -c config.default
End-of-File

# deal with assorted date and times and hostnames and PIDs ...
#
# bozo.localdomain     20220514.13.47    default  1989429 running 
# ...
# /var/log/pcp/pmlogger/1424/2022/05/bozo.localdomain/2022-05-14
# /var/log/pcp/pmlogger/1424/2022/05/bozo.localdomain/2022-05-14/20220514.13.47.index
# and this one may, or may not, be there
# /var/log/pcp/pmlogger/1424/2022/05/bozo.localdomain/2022-05-14/lock
#
_filter()
{
    sed \
	-e '/[0-9][0-9]* running/s//PID running/' \
	-e "s/`date +%Y`-`date +%m`-`date +%d`/YYYY-MM-DD/" \
	-e "s/\([^0-9]\)`date +%Y`/\1YYYY/g" \
	-e "s/YYYY`date +%m`/YYYYMM/g" \
	-e "s@YYYY/`date +%m`@YYYY/MM@g" \
	-e "s/MM`date +%d`/MMDD/g" \
	-e "s@$PCP_ARCHIVE_DIR@PCP_ARCHIVE_DIR@g" \
	-e 's/\.[0-2][0-9]\.[0-5][0-9]/.TIME/g' \
	-e 's/TIME-[0-9][0-9]*/TIME/' \
	-e "s/`hostname`/LOCALHOST/" \
	-e '/\/lock$/d' \
	-e 's/  */ /g' \
    # end
}

# real QA test starts here
$sudo cp $tmp.control $PCP_ETC_DIR/pcp/pmlogger/control.d/$seq
cat $PCP_ETC_DIR/pcp/pmlogger/control.d/$seq >>$seq_full

if ! _service pmlogger restart 2>&1; then _exit 1; fi \
| _filter_pcp_restart
_wait_for_pmlogger || _exit 1

# _wait_for_pmlogger does not quite cut the mustard here ... we
# need two pmloggers to be running ...
#
i=0
maxdelay=20
while [ $i -lt $maxdelay ]
do
    ( cd $PCP_TMP_DIR/pmlogger; find . -type f ) >$tmp.pids
    nlogger=`wc -l <$tmp.pids | sed -e 's/  *//g'`
    if [ "$nlogger" = 2 ]
    then
	break
    fi
    i=`expr $i + 1`
    sleep 1
done
if [ $i -eq $maxdelay ]
then
    echo "Error: failed to start pmloggers ..."
    cat $tmp.pids
    pminfo -f pmcd.pmlogger
fi
cat $tmp.pids | sed -e "s@^./@@" | while read pid
do
    # don't care about log file, and can't tell which pmlogger
    # is which at this stage
    #
    _wait_for_pmlogger $pid /dev/null || _exit 1
done

pmlogctl status \
| _filter \
| LC_COLLATE=POSIX sort

find $PCP_ARCHIVE_DIR/$seq \
| tee -a $seq_full \
| _filter \
| LC_COLLATE=POSIX sort

# success, all done
exit