3 # Exercise adding/removing the netfilter PMDA, reading values
5 # Copyright (c) 2015 Red Hat. All Rights Reserved.
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
16 [ -f $PCP_PMDAS_DIR/netfilter
/pmdanetfilter.pl
] || _notrun
"netfilter pmda not installed"
17 perl
-e "use PCP::PMDA" >/dev
/null
2>&1
18 [ $?
-eq 0 ] || _notrun
"perl PCP::PMDA module not installed"
20 status
=1 # failure is the default!
21 $sudo rm -rf $tmp $tmp.
* $seq.full
22 trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15
24 #setup the tmp proc file system for newer config
25 pmdanetfilter_prepare
()
27 mkdir
-p $tmp/proc
/sys
/net
/netfilter
/
28 touch $tmp/proc
/sys
/net
/netfilter
/nf_conntrack_
{max
,count
}
29 $PCP_ECHO_PROG 15 > $tmp/proc
/sys
/net
/netfilter
/nf_conntrack_max
30 $PCP_ECHO_PROG 34 > $tmp/proc
/sys
/net
/netfilter
/nf_conntrack_count
33 pmdanetfilter_remove
()
36 echo "=== remove netfilter agent ==="
37 $sudo .
/Remove
>$tmp.out
2>&1
38 _filter_pmda_remove
<$tmp.out
39 $sudo rm -rf $tmp $tmp.
*
42 pmdanetfilter_install
()
44 # start from known starting points
45 cd $PCP_PMDAS_DIR/netfilter
46 $sudo .
/Remove
>/dev
/null
2>&1
47 $sudo $PCP_RC_DIR/pmcd stop
2>&1 | _filter_pcp_stop
50 echo "=== netfilter agent installation ==="
51 $sudo .
/Install
<$tmp.input
>$tmp.out
2>&1
52 cat $tmp.out
>>$here/$seq.full
53 # Check netfilter metrics have appeared ... X metrics and Y values
54 _filter_pmda_install
<$tmp.out \
56 -e '/^Waiting for pmcd/s/\.\.\.[. ]*$/DOTS/' \
57 -e 's/[0-9][0-9]* warnings, //' \
59 /Check netfilter metrics have appeared/ { if ($7 >= 0 && $7 <= 2) $7 = "X"
60 if ($10 >= 0 && $10 <= 80) $10 = "Y"
64 # use a temp config file to point at the fake /proc system (newer heirarchy)
70 # load newer proc heirarchy
72 _prepare_pmda netfilter
73 trap "_cleanup_pmda netfilter; exit \$status" 0 1 2 3 15
75 # real QA test starts here
78 # avoid a possible race condition if the pmda is slow starting
81 # test netfilter values
82 pminfo
-f netfilter.ip_conntrack_count
83 pminfo
-f netfilter.ip_conntrack_max
85 # re-install pmdanetfilter with old heirarchy