1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#!/bin/bash
hit_164=`redis-cli -h 192.168.1.164 -p 6379 info Stats|
grep
keyspace_hits|
awk
-F
':'
'{print $2}'
|
sed
-r
's/\r//'
`
mis_164=`redis-cli -h 192.168.1.164 -p 6379 info Stats|
grep
keyspace_misses|
awk
-F
':'
'{print $2}'
|
sed
-r
's/\r//'
`
exr_164=`redis-cli -h 192.168.1.164 -p 6379 info Stats|
grep
expired_keys|
awk
-F
':'
'{print $2}'
|
sed
-r
's/\r//'
`
let
num_164=hit_164+mis_164-exr_164
let
percent_164=(100*hit_164)
/num_164
if
[ $percent_164 -lt 70 ] && [ $percent_164 -
ge
60 ]
then
echo
"Warning!redis hit succeed percents is less than 70%.Now it's $percent_164%."
exit
1
elif
[ $percent_164 -lt 60 ]
then
echo
"CRITICAL!redis hit succeed percents is less than 60%.Now it's $percent_164%."
exit
2
else
echo
"OK!Now redis hit succeed percents is $percent_164%."
exit
0
fi
|
主要思路:通过redis-cli的info命令匹配hits/misses/expired_keys三个字段参数进行百分比计算。
本文转自YU文武貝 51CTO博客,原文链接:http://blog.51cto.com/linuxerxy/1933062,如需转载请自行联系原作者