#!/bin/sh
#if [ $# -ne 2 ]
#then
# echo "Usage:$0 -w num1 -c num2"
#exit 3
#fi
#DATE=`date +%Y-%m-%d`
#curr_connections=`/usr/local/nagios/libexec/check_tcp -H localhost -p 11211 -E -s 'stats\r\nquit\r\n' -e 'uptime' |grep curr_connections | awk '{print $3}'`
cmd_get=`/usr/local/nagios/libexec/check_tcp -H localhost -p 11211 -E -s 'stats\r\nquit\r\n' -e 'uptime' |grep cmd_get | awk '{print $3+0}'`
get_hits=`/usr/local/nagios/libexec/check_tcp -H localhost -p 11211 -E -s 'stats\r\nquit\r\n' -e 'uptime' |grep get_hits | awk '{print $3+0}'`
#limit_maxbytes=`/usr/local/nagios/libexec/check_tcp -H localhost -p 11211 -E -s 'stats\r\nquit\r\n' -e 'uptime' |grep limit_maxbytes | awk '{print $3+0}'`
#threads=`/usr/local/nagios/libexec/check_tcp -H localhost -p 11211 -E -s 'stats\r\nquit\r\n' -e 'uptime' |grep threads | awk '{print $3}'`
#bytes=`/usr/local/nagios/libexec/check_tcp -H localhost -p 11211 -E -s 'stats\r\nquit\r\n' -e 'uptime' |grep bytes |grep -vn '_'|awk '{print $3+0}'`
#curr_items=`/usr/local/nagios/libexec/check_tcp -H localhost -p 11211 -E -s 'stats\r\nquit\r\n' -e 'uptime' |grep curr_items|awk '{print $3}'`
hit_rate=`echo "$get_hits*100/$cmd_get"|bc`
# echo "$hit_rate"
#mem_percentage=`echo "scale=2;100*$bytes/$limit_maxbytes"|bc`
# echo "$mem_percentage"
if [[ $hit_rate -gt $1 ]]
then
echo "OK - hit rate is $hit_rate | hit_rate=$hit_rate; cmd_get=$cmd_get; get_hits=$get_hits"
exit 0
fi
if [[ $hit_rate -lt $2 ]]
then
echo "Critical - hit rate is $hit_rate | hit_rate=$hit_rate; cmd_get=$cmd_get; get_hits=$get_hits"
exit 1
fi
if [[ $hit_rate -lt $1 ]]
then
echo "WARNING - hit rate is $hit_rate | hit_rate=$hit_rate; cmd_get=$cmd_get; get_hits=$get_hits"
exit 2
fi
阅读(2108) | 评论(0) | 转发(0) |