首页 > 代码库 > memcached监控脚本

memcached监控脚本

#!/bin/bash

. /etc/init.d/functions
if [ `netstat -lntup| grep 11211|wc -l` -lt 1 ];then
        action "Memcached Serivce is error." /bin/false
        exit 1
fi

echo -e "del key\r\n"| nc 127.0.0.1 11211 &>/dev/null
echo -e "set key 0 0 10 \r\noldboy1234\r\n" |nc 127.0.0.1 11211 &>/dev/null
MCValues=`echo -e "get key\r\n"|nc 127.0.0.1 11211| grep oldboy1234|wc -l`

if [ $MCValues -eq 1 ];then
        action "Memcached Service Status is OK." /bin/true
else
        action "Memcached Service Status is Error." /bin/false
fi

echo -e 可以替换为 printf

memcached监控脚本