Zabbix Custom script Monitoring Activemq in Super detail
This document is very suitable for students who try to monitor activemq by zabbix for the first time, and it is very detailed (don't give up long-winded ha)
Zabbix Custom Monitoring Activemq
Monitor mq:
Pending unread queue unread
Consumers consumers
Total number of Enqueued queues
Total number of Dequeued outqueues read
1. Zabbix does not have a template like mysql, so you need to write your own script to monitor it.
2. After defining the monitoring items, I use the curl command to monitor
First of all, let's familiarize ourselves with the use of curl.
View the details of all queues in mq (user name and password of mqIP+ access page + queues.jsp | grep)
Curl-s-u admin:admin http://127.0.0.1:8161/admin/queues.jss
Display queue brief information
Curl-s-u admin:admin http://127.0.0.1:8161/admin/queues.jsp|grep''
View all queue information (including consumers, number of queues, etc.)
Curl-s-u admin:admin http://127.0.0.1:8161/admin/queues.jsp|grep''- A 4
View the number of consumers in a queue (consumers, number of queues, numbers out of queues)
Curl-s-u admin:admin http://127.0.0.1:8161/admin/queues.jsp|grep''- A 4 | grep 'se-taskresult'-A 4 | sed-n' 2p' | egrep-o'[0-9] +'
Solution: sed-n '2p'p indicates where to view the monitoring data, indicating unread message queues (3p if you want to view consumers, and so on)
3. Be sure to run the above commands locally according to the actual mq queue before writing the script. Use the script to test locally.
#! / bin/sh
Username=admin
Password=admin
Queuename=$1
Mytype=$2
Case ${mytype} in
"unread")
Curl-s-u "$username:$password"http://127.0.0.1:8161/admin/queues.jsp"|grep" ${queuename} "- A 4 | sed-n '2p' | egrep-o' [0-9] +'
"read")
Curl-s-u "$username:$password"http://127.0.0.1:8161/admin/queues.jsp"|grep" ${queuename} "- A 4 | sed-n '5p' | egrep-o' [0-9] +'
"consumers")
Curl-s-u "$username:$password"http://127.0.0.1:8161/admin/queues.jsp"|grep" ${queuename} "- A 4 | sed-n '3p' | egrep-o' [0-9] +'
"enqueued")
Curl-s-u "$username:$password"http://127.0.0.1:8161/admin/queues.jsp"|grep" ${queuename} "- A 4 | sed-n '4p' | egrep-o' [0-9] +'
*) echo "unsupported"
Esac
4. Script protection path (the script takes effect locally after my initial configuration, but zabbix-sevrer keeps reporting errors due to the location of the script, so be sure to prevent it to / etc/zabbix/zabbix_agentd.d)
5. Test script
(script location + queue name + monitoring value name) the read here is custom
View unread message queuing for se-taskresult message queuing
Sh / etc/zabbix/zabbix_agentd.d/activemq_monitor.sh se-taskresult unread/
The test script is correct (the basic commands above are used here. Haha ~ script verification ~)
6. Add monitoring items to zabbix
Create a template-omitted here
Create a monitoring item on a template
7. Create a .conf file in this directory to specify the path where the script is stored
Vim / etc/zabbix/zabbix_agentd.d/activemq.conf
UserParameter=activemq.monitor [*], sh / etc/zabbix/zabbix_agentd.d/activemq_monitor.sh $1 $2
8. Supplement points (remember to check whether the following configuration is enabled in the zabbix_agentd.conf file)
Include=/etc/zabbix/zabbix_agentd.d/*.conf
9. Create a monitoring graph
10. View the monitoring chart
The above is the whole process of zabbix monitoring activemq. The next blog will explain the details of the script.