File: 1620

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 (168 lines) | stat: -rwxr-xr-x 3,904 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
159
160
161
162
163
164
165
166
167
168
#!/bin/sh
# PCP QA Test No. 1620
# Exercise pmlogger response with a pmproxy SIGHUP.
#
# Copyright (c) 2025 Red Hat.  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

do_valgrind=false
if [ "$1" = "--valgrind" ]
then
    _check_valgrind
    do_valgrind=true
fi

_cleanup()
{
    cd $here
    _restore_config $PCP_SYSCONF_DIR/pmproxy/pmproxy.conf

    [ -d $archive_path ] && $sudo rm -fr $archive_path
    if $pmproxy_was_running
    then
        echo "Restart pmproxy ..." >>$seq_full
        _service pmproxy restart >>$seq_full 2>&1
        _wait_for_pmproxy
    else
        echo "Stopping pmproxy ..." >>$seq_full
        _service pmproxy stop >>$seq_full 2>&1
    fi
    _restore_auto_restart pmproxy

    $sudo rm -rf $tmp $tmp.*
}

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

_filter()
{
    sed \
	-e "s@$tmp@TMP@g" \
	-e "s@$archive_path@ARCHIVE_PATH@g" \
	-e "s/TMP\.data\./LOCAL_ARCHIVE./g" \
	-e "s/2[0-9][0-9]*\.[0-9][0-9]\.[0-9][0-9]\./REMOTE_ARCHIVE./g" \
	-e "s/2[0-9][0-9]*\.[0-9][0-9]\.[0-9][0-9]-[0-9][0-9]\./REMOTE_ARCHIVE./g" \
    # end
}

_filter_metrics()
{
    sed \
	-e "/^pmcd\.*/d" \
	-e "/^event\.*/d" \
    | LC_COLLATE=POSIX sort
}

_save_logs()
{
    echo === pmlogger log >> $seq_full
    cat pmlogger.log >> $seq_full
    echo === pmproxy log >> $seq_full
    cat $PCP_LOG_DIR/pmproxy/pmproxy.log >> $seq_full
}

# real QA test starts here
archive_host=`hostname`
archive_path=$PCP_REMOTE_ARCHIVE_DIR/$archive_host
archive_botch=$PCP_LOG_DIR/pmproxy/pmproxy

pmproxy_was_running=false
[ -f $PCP_RUN_DIR/pmproxy.pid ] && pmproxy_was_running=true
echo "pmproxy_was_running=$pmproxy_was_running" >>$seq_full

_save_config $PCP_SYSCONF_DIR/pmproxy/pmproxy.conf

_stop_auto_restart pmproxy
if ! _service pmproxy stop >>$seq_full 2>&1; then _exit 1; fi

$sudo rm -fr $archive_path $archive_botch

# pmproxy config
cat >$tmp.conf << End-Of-File
# Installed by PCP QA test $seq on `date`
[pmproxy]
pcp.enabled = false
http.enabled = true
[pmlogger]
enabled = true
[discover]
enabled = false
[pmseries]
enabled = false
End-Of-File
$sudo cp $tmp.conf $PCP_SYSCONF_DIR/pmproxy/pmproxy.conf

if ! _service pmproxy start 2>&1; then _exit 1; fi | _filter_pmproxy_start
_wait_for_pmproxy || _exit 1
pmproxy_pid=`cat $PCP_RUN_DIR/pmproxy.pid`

PCP_DERIVED_CONFIG=""; export PCP_DERIVED_CONFIG

# pmlogger config
cat >$tmp.conf << End-Of-File
log mandatory on once {
    hinv.ncpu
    hinv.ndisk
}
log mandatory on every 1 second {
    disk.all.read
    disk.all.write
    kernel.all.load
    kernel.all.pswitch
}
End-Of-File

echo "=== Running pmlogger in remote recording mode"
remote_mode="-c $tmp.conf -T 15sec http://localhost:44322"
((sleep 10; $sudo $signal -s HUP $pmproxy_pid)&) >/dev/null 2>&1
if $do_valgrind
then
    _run_valgrind pmlogger $remote_mode
else
    pmlogger $remote_mode
fi \
| _filter
# pmlogger has been running for 15sec, plenty long enough
# for sleep 10; send signal; pmproxy to catch signal

echo "## checking for pmproxy SIGHUP"
grep SIGHUP $PCP_REMOTE_ARCHIVE_DIR/pmproxy.log | _filter_pmproxy_log
_save_logs

if [ -d $archive_path ]
then
    echo "## found remote archive files"
    ls -1 $archive_path | tee -a $seq_full | _filter | LC_COLLATE=POSIX sort
    echo "## with the following metrics"
    pminfo -a $archive_path | _filter_metrics
else
    echo "Archive push failed: $archive_path directory not created"
    status=1
    exit
fi
if [ -d $archive_botch ]
then
    echo "Bad archive path $archive_botch found but should not be"
    status=1
    exit
fi

# success, all done
exit