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

posted @ 2017-03-24 17:59  Vincen_shen  阅读(314)  评论(0编辑  收藏  举报