1.碰到windows上面的redis服务,在windows写脚本又麻烦又不好操控,所以我是在linux机器上面用shell脚本连接查看info来实现的,跟上一篇很像,脚本类似。
vim redisStatus_windows.sh 编写脚本:
#!/bin/bash
REDISCLI="/usr/local/bin/redis-cli"
HOST="windows机器的公网IP"
PASS="password"
if [[ $# == 1 ]];then
case $1 in
version_test)
result=`$REDISCLI -h $HOST -a $PASS -p 6379 info server 2>/dev/null | grep -w "redis_version" | awk -F':' '{print $2}'`
echo $result
;;
total_commands_processed_test)
result=`$REDISCLI -h $HOST -a $PASS -p 6379 info 2>/dev/null | grep -w "total_commands_processed" | awk -F':' '{print $2}'`
echo $result
;;
instantaneous_ops_per_sec_test)
result=`$REDISCLI -h $HOST -a $PASS -p 6379 info 2>/dev/null | grep -w "instantaneous_ops_per_sec" | awk -F':' '{print $2}'`
echo $result
;;
instantaneous_input_kbps_test)
result=`$REDISCLI -h $HOST -a $PASS -p 6379 info 2>/dev/null | grep -w "instantaneous_input_kbps" | awk -F':' '{print $2}'`
echo $result
;;
instantaneous_output_kbps_test)
result=`$REDISCLI -h $HOST -a $PASS -p 6379 info 2>/dev/null | grep -w "instantaneous_output_kbps" | awk -F':' '{print $2}'`