3 # Exercise the memcache PMDA - install, remove and values.
5 # Copyright (c) 2014-2015 Red Hat.
6 # Copyright (c) 2014 Ken McDonell. All Rights Reserved.
7 # Copyright (c) 2008 Aconex. All Rights Reserved. (based on qa/348)
11 echo "QA output created by $seq"
13 # get standard environment, filters and checks
18 [ -d $PCP_PMDAS_DIR/memcache
] || _notrun
"memcache PMDA directory is not installed"
21 $PCP_BINADM_DIR/telnet-probe
-c localhost
$port || \
22 _notrun
"Noones home on the default memcached port $port"
24 status
=1 # failure is the default!
25 $sudo rm -rf $tmp.
* $seq.full
30 echo "=== remove memcache agent ==="
31 $sudo .
/Remove
>$tmp.out
2>&1
32 _filter_pmda_remove
<$tmp.out
35 pmdamemcache_install
()
37 # start from known starting points
38 cd $PCP_PMDAS_DIR/memcache
39 $sudo .
/Remove
>/dev
/null
2>&1
40 $sudo $PCP_RC_DIR/pmcd stop
42 cat <<EOF >$tmp.config
44 @memcache_instances = ( 0 => '127.0.0.1:11211' );
46 echo "pmdamemcache config:" >> $here/$seq.full
47 cat $tmp.config
>> $here/$seq.full
49 [ -f $PCP_PMDAS_DIR/memcache
/memcache.conf
] && \
50 $sudo cp $PCP_PMDAS_DIR/memcache
/memcache.conf
$tmp.backup
51 $sudo cp $tmp.config
$PCP_PMDAS_DIR/memcache
/memcache.conf
54 echo "=== memcache agent installation ==="
55 $sudo .
/Install
</dev
/null
>$tmp.out
2>&1
56 # Check metrics have appeared ... X metrics and Y values
57 _filter_pmda_install
<$tmp.out \
59 -e '/^Waiting for pmcd/s/\.\.\.[. ]*$/DOTS/' \
61 /Check memcache metrics have appeared/ { if ($7 >= 16 && $7 <= 50) $7 = "X"
62 if ($10 >= 16 && $10 <= 50) $10 = "Y"
67 pmdamemcache_cleanup
()
69 if [ -f $tmp.backup
]; then
70 $sudo cp $tmp.backup
$PCP_PMDAS_DIR/memcache
/memcache.conf
73 $sudo rm -f $PCP_PMDAS_DIR/memcache
/memcache.conf
75 _cleanup_pmda memcache
78 _prepare_pmda memcache
79 trap "pmdamemcache_cleanup; exit \$status" 0 1 2 3 15
81 # make pmprobe output comparable to memcachestats
82 rewrite_memcache_metric_names
()
85 -e 's/^memcache.//g' \
86 -e 's/^gets /cmd_get /g' \
87 -e 's/^sets /cmd_set /g' \
88 -e 's/^hits /get_hits /g' \
89 -e 's/^misses /get_misses /g' \
90 -e 's/^current_items/curr_items/g' \
91 -e 's/^current_connections/curr_connections/g' \
95 # real QA test starts here
99 echo "=== extract metric values ==="
100 pmprobe
-v memcache \
101 | rewrite_memcache_metric_names \
102 | LC_COLLATE
=POSIX
sort >$tmp.probe
103 echo "from pmprobe ..." >>$here/$seq.full
105 $here/src
/memcachestats.pl \
106 |
sed -e 's/ / 1 /' \
107 | LC_COLLATE
=POSIX
sort >$tmp.values
108 echo "from src/memcachestats.pl ..." >>$here/$seq.full
110 cat $tmp.values
>>$here/$seq.full
111 LC_COLLATE
=POSIX
join $tmp.probe
$tmp.values
>$tmp.all
112 echo >>$here/$seq.full
113 cat $tmp.all
>>$here/$seq.full
116 echo "=== check values ==="
118 |
while read metric n1 vpcp n2 vmemcache
120 if [ "$n1" = 1 -a "$n2" = 1 ]
124 bytes_read|bytes_written
)
125 # unstable, skip these ones
127 curr_connections|connection_structures
)
129 _within_tolerance
$metric $vpcp $vmemcache 2 -v
133 _within_tolerance
$metric $vpcp $vmemcache 5 -v
137 _within_tolerance
$metric $vpcp $vmemcache 10% -v
141 echo "$metric: number of values not 1 as expected: pcp $n1 / memcache $n2"
143 done |
tee -a $here/$seq.full