getRedisBigkeys.sh

时间:2021-09-17
本文章向大家介绍getRedisBigkeys.sh,主要包括getRedisBigkeys.sh使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
#!/bin/bash
func() {
            echo "Usage:"
            echo "      bigkeys [options]"
            echo ""
            echo "General Options:"
            echo "      -H          Show help."
            echo "      -h          Server hostname (default: 127.0.0.1)"
            echo "      -p          Server port (default: 6379)"
            echo "      -a          Password to use when connecting to the server."
}

func_getRedisBigkeys(){
           #redis_path=`ps -ef |grep -i redis-server|grep -v grep |awk '{print $8}'`
           #cli=`$redis_path|sed -e "s/redis-server/redis-cli/g"`
           if [ -z $3 ]; then
              redis-cli --bigkeys -h $1 -p $2
           else
              redis-cli --bigkeys -h $1 -p $2 -a $3
           fi
}

while getopts ":HBh:p:a:" opt; do
  case ${opt} in
    H )
       func
      ;;
    h )
      host=$OPTARG
      ;;
    p )
      port=$OPTARG
      ;;
    a )
      password=$OPTARG
      ;;
    B )
      echo "******get redis bigkeys******"
      #func_getRedis
      ;;
#    b )
#      base_path=$OPTARG
#      ;;
    \? )
      func
      ;;
  esac
done
shift $(($OPTIND - 1))

if [ -z $host ]; then
   host='127.0.0.1'
fi

if [ -z $port ]; then
   port=6379
fi

#if [ -z $base_path ]; then
#     echo "请输入redis主目录"
#     exit 1
#fi

func_getRedisBigkeys $host $port $password

原文地址:https://www.cnblogs.com/litzhiai/p/15305157.html