码迷,mamicode.com
首页 > 其他好文 > 详细

RabbitMQ队列监控

时间:2016-12-12 19:04:31      阅读:557      评论:0      收藏:0      [点我收藏+]

标签:sudo   ons   param   code   个数   png   com   row   获取   

Idle:通过自动发现队列,获取各个队列中的ready,unackd等值

sudo !!!

 技术分享

 1  #!/bin/sh
 2   discovery(){
 3    Queue=(`rabbitmqctl list_queues |grep -v List |awk {print $1}`)
 4    len=${#Queue[@]}
 5    printf "{\n"
 6    printf  \t‘"\"data\":["
 7    for ((i=0;i<$len;i++))
 8    do
 9      printf \n\t\t{
10      printf "\"{#MQ_NAME}\":\"${Queue[$i]}\"}"
11      if [ $i -lt $[$len-1] ];then
12        printf ,
13      fi
14    done
15    printf  "\n\t]\n"
16    printf "}\n"
17  
18    }
19 
20 21 22 messages(){ 23 QUEUE=$1 24 ROW=`rabbitmqctl list_queues |grep -n $QUEUE |awk -F : {print $1}` 25 MESSAGES=`rabbitmqctl list_queues messages |awk NR=="‘‘‘$ROW‘‘‘"{print}` 26 echo $MESSAGES 27 } 28 ready(){ 29 QUEUE=$1 30 ROW=`rabbitmqctl list_queues |grep -n $QUEUE |awk -F : {print $1}` 31 READY=`rabbitmqctl list_queues messages_ready |awk NR=="‘‘‘$ROW‘‘‘"{print}` 32 echo $READY 33 } 34 unack(){ 35 QUEUE=$1 36 ROW=`rabbitmqctl list_queues |grep -n $QUEUE |awk -F : {print $1}` 37 UNACK=`rabbitmqctl list_queues messages_unacknowledged |awk NR=="‘‘‘$ROW‘‘‘"{print}` 38 echo $UNACK 39 } 40 41 42 if [ $1 == "discovery" ]; then 43 discovery 44 elif [ $1 == "messages" ]; then 45 messages $2 46 elif [ $1 == "ready" ]; then 47 ready $2 48 elif [ $1 == "unack" ]; then 49 unack $2 50 fi

 


  1 UserParameter=rabbitmq.discovery_queue[*],sh /etc/zabbix/zabbix_source/rabbitmq.sh  $1        ###自动发现队列
  2 UserParameter=rabbitmq.queue.list,  sudo rabbitmqctl  list_queues |wc -l                  ###队列个数
  3 UserParameter=rabbitmq.consumer.list,  sudo rabbitmqctl  list_consumers |wc -l                  ###消费者个数
  4 UserParameter=rabbitmq.total.messages[*],  sh /etc/zabbix/zabbix_source/rabbitmq.sh  messages $1  ###总消息
  5 UserParameter=rabbitmq.message.ready[*],   sh /etc/zabbix/zabbix_source/rabbitmq.sh  ready    $1  ###生产数
  6 UserParameter=rabbitmq.message.unackd[*],  sh /etc/zabbix/zabbix_source/rabbitmq.sh  unack    $1  ###未消费数

 

RabbitMQ队列监控

标签:sudo   ons   param   code   个数   png   com   row   获取   

原文地址:http://www.cnblogs.com/xfbc/p/6165384.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!