一段分析Memcached每秒读写脚本

一段分析Memcached每秒读写脚本



#!/bin/bash
if [ $# -lt 2 ]
then
        echo "usage: $0 ip port <stats_para>"
        echo "example: $0  xxx.xxx.xxx.xxx 11211 cmd_get"
        exit 1
fi
mc_ip=$1
shift
mc_port=$1
shift
if [ -n $1 ]; then
        cmd=$1
else
        cmd="cmd_get"
fi
count1=`(echo stats;sleep 0.001;echo quit)|nc $mc_ip $mc_port|grep "$cmd"|awk -F" " '{print $3}'|awk -F"\r" '{print $1}'`
echo "now $cmd: $count1"
while : ; do
        count1=`(echo stats;sleep 0.001;echo quit)|nc $mc_ip $mc_port|grep "$cmd"|awk -F" " '{print $3}'|awk -F"\r" '{print $1}'`
        sleep 1
        count2=`(echo stats;sleep 0.001;echo quit)|nc $mc_ip $mc_port|grep "$cmd"|awk -F" " '{print $3}'|awk -F"\r" '{print $1}'`
        #((res=$count2-$count1))
        res=`echo "scale=0;$count2-$count1"|bc`
        echo $res
done




结果类似:

获取每秒get命令数量


获取每秒set命令数量


你可能感兴趣的:(memcached,iops)