监控脚本如下:zabbix_monitor_amq.sh
#!/bin/sh # #Description: get activemq data IP=192.168.0.139 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
2.编辑zabbix_agentd.conf
#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
3.编写item
4.或者上传附件的监控模板
本文出自 “不求最好,只求更好” 博客,请务必保留此出处http://yujianglei.blog.51cto.com/7215578/1773826
原文地址:http://yujianglei.blog.51cto.com/7215578/1773826