#!/bin/sh
# filename: mon_mc.sh
export MemcahedIp=$1
export MemcahedPort=$2
export NcCmd="nc $MemcahedIp $MemcachedPort"
export MD5=3fe396c01f03425cb5e2da8186ev090d
USAGE(){
echo "$0 MemcachedIp MemcachedPort"
exit 3
}
[ $# -ne 2 ] && USAGE
printf "set $MD5 0 0 6\r\noldboy\r\n" | $NcCmd > /dev/null 2>&1
if [ $? -eq 0 ];then
if [ `printf "get $MD5\r\n"|$NcCmd | grep oldboy | wc -l` -eq 1 ];then
echo "Memcahed status is ok"
printf "delete $MD5\r\n"|$NcCmd >/dev/null 2>&1
exit 0
else
echo "Memcached status is error"
exit 2
fi
else
echo "cound not connect Mc server"
exit 2
fi
时间: 2024-11-07 01:49:12