说明:
线上需要,添加了JMS消息队列的功能.针对消息队列,我做了如下的监控:
(1)队列中正在处理的数量(Pending messages)
(2)出队列总量(Dequeued messages)
(3)进队列的数量(Enqueud messages)
(4)死信队列的数量(DLQ)
这四者的关系:
Dequeued messages=Pending messages+Enqueud messages+DLQ
1.配置zabbix客户端,编辑每个acitvemq主机的zabbix_agentd.conf,自定义key值
#Monitor ActiveMQ UserParameter=activemq.pending,/etc/zabbix/scripts/check_activemq.sh Pending UserParameter=activemq.consumers,/etc/zabbix/scripts/check_activemq.sh consumers UserParameter=activemq.enqueued,/etc/zabbix/scripts/check_activemq.sh enqueued UserParameter=activemq.dequeued,/etc/zabbix/scripts/check_activemq.sh dequeued UserParameter=activemq.warn_pending,/etc/zabbix/scripts/check_activemq.sh Warn_Pending
2.编辑监控监控check_activemq.sh
vi check_activemq.sh #!/bin/bash # #Description: get activemq data # #Var IP=192.168.0.133 PORT=8161 QUEUENAME=q.virtual.charge #WARN_Queuename="DLQ.q.virtual.charge" WARN_Queuename="DLQ.*" Warn_Pending=`curl -uadmin:admin http://$IP:$PORT/admin/queues.jsp | grep -A 5 "${WARN_Queuename}</a></td>"|awk -F '<' '{print $2}'|sed 's/td>//g'|grep '^[0-9]'|head -1` Pending=`curl -uadmin:admin http://$IP:$PORT/admin/queues.jsp | grep -A 5 "${QUEUENAME}</a></td>"|awk -F '<' '{print $2}'|sed 's/td>//g'|grep '^[0-9]'|head -1` Consumers=`curl -uadmin:admin http://$IP:$PORT/admin/queues.jsp | grep -A 5 "${QUEUENAME}</a></td>"|awk -F '<' '{print $2}'|sed 's/td>//g'|grep '^[0-9]'|head -2|tail -1` Enqueued=`curl -uadmin:admin http://$IP:$PORT/admin/queues.jsp | grep -A 5 "${QUEUENAME}</a></td>"|awk -F '<' '{print $2}'|sed 's/td>//g'|grep '^[0-9]'|head -3|tail -1` Dequeued=`curl -uadmin:admin http://$IP:$PORT/admin/queues.jsp | grep -A 5 "${QUEUENAME}</a></td>"|awk -F '<' '{print $2}'|sed 's/td>//g'|grep '^[0-9]'|head -3|tail -1` case $1 in Warn_Pending|Warn_Pending) echo "$Warn_Pending" ;; Pending|pending) echo "$Pending" ;; Consumers|consumers) echo $Consumers ;; Enqueued|enqueued) echo $Enqueued ;; Dequeued|dequeued) echo $Dequeued ;; *) echo "Usage: $0 Pending|Consumers|Enqueued|Dequeued|Warn_Pending" esac
3.重启zabbix客户端
/etc/init.d/zabbix_agentd stop /usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agetnd.conf
4.创建zabbix监控JMS--ActiveMQ的模板,(监控项,触发器),或者下载我创建好的模板,见附件
5.监控图如下
转载于:https://blog.51cto.com/yujianglei/1725486