pmrep: really drop non-ascii
[pcp.git] / qa / 855
blob501a61b0aad8fc8754b5493d76f5f11308442ea0
1 #!/bin/sh
2 # PCP QA Test No. 855
3 # Exercise adding/removing the netfilter PMDA, reading values
5 # Copyright (c) 2015 Red Hat. All Rights Reserved.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
12 . ./common.product
13 . ./common.filter
14 . ./common.check
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()
35 echo
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
49 echo
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 \
55 | sed \
56 -e '/^Waiting for pmcd/s/\.\.\.[. ]*$/DOTS/' \
57 -e 's/[0-9][0-9]* warnings, //' \
58 | $PCP_AWK_PROG '
59 /Check netfilter metrics have appeared/ { if ($7 >= 0 && $7 <= 2) $7 = "X"
60 if ($10 >= 0 && $10 <= 80) $10 = "Y"
62 { print }'
64 # use a temp config file to point at the fake /proc system (newer heirarchy)
65 cat >$tmp.input <<EOF
67 $tmp/proc/sys/net/
68 EOF
70 # load newer proc heirarchy
71 pmdanetfilter_prepare
72 _prepare_pmda netfilter
73 trap "_cleanup_pmda netfilter; exit \$status" 0 1 2 3 15
75 # real QA test starts here
76 pmdanetfilter_install
78 # avoid a possible race condition if the pmda is slow starting
79 sleep 3
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
86 pmdanetfilter_remove
88 # success, all done
89 status=0
91 exit
92 pminfo -f netfilter
94 pmdanetfilter_remove
95 # success, all done
96 status=0
98 exit