• 获取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 ~]$
  • 相关阅读:
    瀑布流-03-通过封装的自定义布局快速实现商品展示
    瀑布流-02-手把手教你封装自定义布局
    瀑布流-01-自定义布局实现绚丽的瀑布流
    CoreAnimation-09-模拟时钟
    CoreAnimation-08-CATransition
    CoreAnimation-07-CAAnimationGroup
    CoreAnimation-06-CAKeyframeAnimation
    CoreAnimation-05-CABasicAnimation
    CoreAnimation-04-核心动画必备基础
    logstash+elasticsearch 错误摘记
  • 原文地址:https://www.cnblogs.com/imdba/p/10216564.html
Copyright © 2020-2023  润新知