blob: c943131ddbbc7da2a98dbb999046cfa7d1f75a87 (
plain)
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
|
#!/bin/sh
# PCP QA Test No. 835
# Exercise the memcache PMDA - install, remove and values.
#
# Copyright (c) 2014 Red Hat.
# Copyright (c) 2014 Ken McDonell. All Rights Reserved.
# Copyright (c) 2008 Aconex. All Rights Reserved. (based on qa/348)
#
seq=`basename $0`
echo "QA output created by $seq"
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
port=11211
echo stats | $PCP_BINADM_DIR/telnet-probe localhost $port || \
_notrun "Noones home on the default memcached port $port"
status=1 # failure is the default!
$sudo rm -rf $tmp.* $seq.full
pmdamemcache_remove()
{
echo
echo "=== remove memcache agent ==="
$sudo ./Remove >$tmp.out 2>&1
_filter_pmda_remove <$tmp.out
}
pmdamemcache_install()
{
# start from known starting points
cd $PCP_PMDAS_DIR/memcache
$sudo ./Remove >/dev/null 2>&1
$sudo $PCP_RC_DIR/pmcd stop
cat <<EOF >$tmp.config
$memcache_delay = 1;
@memcache_instances = ( 0 => '127.0.0.1:11211' );
EOF
echo "pmdamemcache config:" >> $here/$seq.full
cat $tmp.config >> $here/$seq.full
[ -f $PCP_PMDAS_DIR/memcache/memcache.conf ] && \
$sudo cp $PCP_PMDAS_DIR/memcache/memcache.conf $tmp.backup
$sudo cp $tmp.config $PCP_PMDAS_DIR/memcache/memcache.conf
echo
echo "=== memcache agent installation ==="
$sudo ./Install </dev/null >$tmp.out 2>&1
# Check metrics have appeared ... X metrics and Y values
_filter_pmda_install <$tmp.out \
| sed \
-e '/^Waiting for pmcd/s/\.\.\.[. ]*$/DOTS/' \
| $PCP_AWK_PROG '
/Check memcache metrics have appeared/ { if ($7 >= 16 && $7 <= 50) $7 = "X"
if ($10 >= 16 && $10 <= 50) $10 = "Y"
}
{ print }'
}
pmdamemcache_cleanup()
{
if [ -f $tmp.backup ]; then
$sudo cp $tmp.backup $PCP_PMDAS_DIR/memcache/memcache.conf
$sudo rm $tmp.backup
else
$sudo rm -f $PCP_PMDAS_DIR/memcache/memcache.conf
fi
_cleanup_pmda memcache
}
_prepare_pmda memcache
trap "cd $here; rm -fr $tmp.*; exit \$status" 0 1 2 3 15
trap "pmdamemcache_cleanup; exit \$status" 0 1 2 3 15
# make pmprobe output comparable to memcachestats
rewrite_memcache_metric_names()
{
sed \
-e 's/^memcache.//g' \
-e 's/^gets /cmd_get /g' \
-e 's/^sets /cmd_set /g' \
-e 's/^hits /get_hits /g' \
-e 's/^misses /get_misses /g' \
-e 's/^current_items/curr_items/g' \
-e 's/^current_connections/curr_connections/g' \
#end#
}
# real QA test starts here
pmdamemcache_install
echo
echo "=== extract metric values ==="
pmprobe -v memcache \
| rewrite_memcache_metric_names \
| LC_COLLATE=POSIX sort >$tmp.probe
echo "from pmprobe ..." >>$here/$seq.full
$here/src/memcachestats.pl \
| sed -e 's/ / 1 /' \
| LC_COLLATE=POSIX sort >$tmp.values
echo "from src/memcachestats.pl ..." >>$here/$seq.full
cat $tmp.values >>$here/$seq.full
LC_COLLATE=POSIX join $tmp.probe $tmp.values >$tmp.all
echo >>$here/$seq.full
cat $tmp.all >>$here/$seq.full
echo
echo "=== check values ==="
cat $tmp.all \
| while read metric n1 vpcp n2 vmemcache
do
if [ "$n1" = 1 -a "$n2" = 1 ]
then
case $metric
in
total_connections)
_within_tolerance $metric $vpcp $vmemcache 5 -v
;;
*)
_within_tolerance $metric $vpcp $vmemcache 10% -v
;;
esac
else
echo "$metric: number of values not 1 as expected: pcp $n1 / memcache $n2"
fi
done | tee -a $here/$seq.full
pmdamemcache_remove
status=0
exit
|