标签:
#!/bin/bash STAT_OK=0 STAT_WARNING=1 STAT_CRITICAL=2 STAT_UNKNOWN=3 rds=‘/home/rediserver/bin/redis-cli‘ stats=`$rds info Stats` ]+/,"","g",$1)}‘`ho "$stats"| awk ‘/keyspace_hits/{print gensub(/[a-z_:\n ]+/,"","g",$1)}‘`echo "$stats"| awk ‘/keyspace_misses/{print gensub(/[a-z_:\n ]+/,"","g",$1)}‘`o "$stats"|awk ‘/expired_keys/{print gensub(/[a-z_:\n summary="keyspace_hits:$keyspace_hits keyspace_misses:$keyspace_misses expired_keys:$expired_keys" pmem=`ps -eo pmem,rsz,comm,pcpu|grep redis-server` eval $(echo $pmem|awk ‘{print "precent="$1,"res="$2,"name="$3,"cpu="$4}‘) prec=`echo $precent|awk ‘{print int($1)}‘` mem=$[ $res/1024] msg_ok="Memory OK - Used: $precent%,${mem}MB,CPU: $cpu% $name | $summary" msg_warn="Memory Warning - Used: $precent%,${mem}MB,CPU: $cpu% $name | $summary" msg_critical="Memory Critical - Used: $precent%,${mem}MB,CPU: $cpu% $name | $summary" if [ $prec -gt 90 ];then echo $msg_critical exit $STAT_CRITICAL elif [ $prec -gt 80 ];then echo $msg_warn exit $STAT_WARNING else echo $msg_ok exit $STAT_OK fi
标签:
原文地址:http://my.oschina.net/u/1011578/blog/490337