File: 1155

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 (128 lines) | stat: -rwxr-xr-x 3,125 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
#!/bin/sh
# PCP QA Test No. 1155
# Exercise the BCC PMDA tcplife module - install, remove and values.
#
# Copyright (c) 2018 Andreas Gerstmayr.
#

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

. ./common.bcc

_pmdabcc_check
which curl >/dev/null 2>&1 || _notrun "No curl binary installed"
[ "$(pmpython src/bcc_version_check.python)" = "0.6.1" ] \
  && _notrun "Broken BCC version detected"
case "`uname -srm`"
in
    Linux\ 5.2.*)
    		_notrun "Bad Linux 5.2 kernel headers will cause BPF to fail"
		;;
esac

target_ip=1.1.1.1

status=1       # failure is the default!
signal=$PCP_BINADM_DIR/pmsignal

# Some combinations of distro and kernel are known to be "bad"
# for some BPF modules
#
kernel=`uname -r`
echo "$kernel" >>$seq_full
case `admin/whatami`
in
    *Fedora\ 32\ *)
	_notrun "bcc tcplife module will not compile on Fedora 32"
	;;
    *Ubuntu\ 19.10\ *)
	_notrun "bcc tcplife module will not compile on Ubuntu 19.10"
	;;
    *Ubuntu\ 20.04\ *)
	# works on 5.4 kernel, not on 5.8.0-1033-azure
	#
	case "$kernel"
	in
	    5.8.0-*-azure)
		_notrun "bcc tcplife module will not compile on Ubuntu kernel $kernel"
		;;
	esac
	;;
    *openSUSE\ Leap\ 15.1\ *)
	_notrun "bcc tcplife module will not compile on openSUSE 15.1"
	;;
esac

_install_filter()
{
    sed \
    -e "s/Using BPF source file .\+/Using BPF source file X/g" \
    #end
}

cat <<EOF >$tmp.conf
# Installed by PCP QA test $seq on `date`
[pmda]
modules = tcplife
prefix = bcc.
[tcplife]
module = tcplife
cluster = 3
dport = 80
EOF

_pmdabcc_try_compile $tmp.conf

_prepare_pmda bcc
trap "_pmdabcc_cleanup; exit \$status" 0 1 2 3 15
_stop_auto_restart pmcd

_pmdabcc_install <$tmp.conf | _install_filter
_pmdabcc_wait_for_metric

# Generate system activity for the BCC tcplife module
curl -s http://${target_ip} > /dev/null

_pmdabcc_wait_for_value bcc.proc.io.net.tcp.pid

echo "=== report metric values for pid ==="
pminfo -dfmtT bcc.proc.io.net.tcp.pid 2>&1 | tee -a $seq_full \
| _value_filter_nonzero

echo "=== report metric values for comm ==="
pminfo -dfmtT bcc.proc.io.net.tcp.comm 2>&1 | tee -a $seq_full \
| _value_filter_exact '"curl"'

echo "=== report metric values for laddr ==="
pminfo -dfmtT bcc.proc.io.net.tcp.laddr 2>&1 | tee -a $seq_full \
| _value_filter_any

echo "=== report metric values for lport ==="
pminfo -dfmtT bcc.proc.io.net.tcp.lport 2>&1 | tee -a $seq_full \
| _value_filter_nonzero

echo "=== report metric values for daddr ==="
pminfo -dfmtT bcc.proc.io.net.tcp.daddr 2>&1 | tee -a $seq_full \
| _value_filter_exact '"'${target_ip}'"'

echo "=== report metric values for dport ==="
pminfo -dfmtT bcc.proc.io.net.tcp.dport 2>&1 | tee -a $seq_full \
| _value_filter_exact 80

echo "=== report metric values for tx ==="
pminfo -dfmtT bcc.proc.io.net.tcp.tx 2>&1 | tee -a $seq_full \
| _value_filter_nonzero

echo "=== report metric values for rx ==="
pminfo -dfmtT bcc.proc.io.net.tcp.rx 2>&1 | tee -a $seq_full \
| _value_filter_nonzero

echo "=== report metric values for duration ==="
pminfo -dfmtT bcc.proc.io.net.tcp.duration 2>&1 | tee -a $seq_full \
| _value_filter_nonzero

_pmdabcc_remove

status=0
exit