• 获取redis cluster中所有节点的内存使用情况


    需求:获取redis cluster集群中所有节点的内存使用情况。

    ip_port=`redis-cli -h $1 -p $2 -a abc123 -c cluster nodes | awk '{print $2}' | awk -F'@' '{print $1}'`
    
    for i in $ip_port
    do
      redis_ip=`echo $i | awk -F':' '{print $1}'|sed 's/
    //g'`
      redis_port=`echo $i | awk -F':' '{print $2}'|sed 's/
    //g'`
      redis_cmd="redis-cli -h $redis_ip -p $redis_port -a abc123 -c"
      $redis_cmd info all > info.txt
      used=$(cat info.txt | grep -w used_memory_rss_human | awk -F":" '{print $2}'| sed 's/
    //g')
      max=$(cat info.txt | grep -w maxmemory_human | awk -F":" '{print $2}'|sed 's/
    //g')
      system=$(cat info.txt | grep -w total_system_memory_human | awk -F":" '{print $2}'|sed 's/
    //g')
      role=$(cat info.txt | grep -w role | awk -F":" '{print $2}'|sed 's/
    //g')
      printf "%s	%s	%s	%s	%s	%s
    " "redis_ip="$redis_ip "redis_port="$redis_port "redis_role="$role "used="$used "max="$max "system="$system
      rm -rf info.txt
    done

    测试:

    [redis@lxd-vm1 ~]$ sh get_redis_memory.sh 5.5.5.101 29001
    redis_ip=5.5.5.102      redis_port=29001      redis_role=slave       used=2.95M      max=1.00G      system=2.82G
    redis_ip=5.5.5.101      redis_port=29001      redis_role=master      used=2.98M      max=1.00G      system=2.82G
    redis_ip=5.5.5.103      redis_port=29002      redis_role=slave       used=2.80M      max=1.00G      system=1.83G
    redis_ip=5.5.5.102      redis_port=29002      redis_role=master      used=2.85M      max=1.00G      system=2.82G
    redis_ip=5.5.5.101      redis_port=29003      redis_role=slave       used=2.99M      max=1.00G      system=2.82G
    redis_ip=5.5.5.103      redis_port=29003      redis_role=master      used=3.02M      max=1.00G      system=1.83G
    [redis@lxd-vm1 ~]$
  • 相关阅读:
    Visual Studio调试提示未能找到路径 bin oslyncsc.exe
    泛型
    Java中System.setProperty()
    jQuery的基础·知识
    移动端事件与touch.js库(js)
    js中,求1~100之间的质数
    匿名函数,闭包与ajax(js)
    正则(js)
    面向对象的概念,创建,实例,call与apply,继承(js)
    事件基础,事件绑定,DOM事件流与事件的默认行为,键盘事件,滚轮事件,事件委托(js)
  • 原文地址:https://www.cnblogs.com/imdba/p/10216564.html
Copyright © 2020-2023  润新知