Ask Your Question
0

How can a customized trigger be established for RabbitMQ queues in Zabbix?

asked 2021-07-18 11:00:00 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-08-23 23:00:00 +0000

djk gravatar image

To establish a customized trigger for RabbitMQ queues in Zabbix, follow these steps:

  1. Install the Zabbix agent and the RabbitMQ plugin on the server hosting RabbitMQ.
  2. Configure the Zabbix agent to monitor the RabbitMQ queues by adding the following lines to its configuration file:
UserParameter=rabbitmq.queue.discovery[*],sudo /etc/zabbix/scripts/rabbitmq-discovery.sh queue $1
UserParameter=rabbitmq.queue.items[*],sudo /etc/zabbix/scripts/rabbitmq-items.sh queue "$1" "$2"
  1. Create a script to discover the RabbitMQ queues, such as the following rabbitmq-discovery.sh script:
#!/bin/bash

queues=$(sudo rabbitmqctl list_queues -q | awk '{ print $1 }')

echo -n '{"data":['
for q in $queues; do
  echo -n "{\"{#QUEUE}\":\"$q\"},"
done | sed -e 's:\},$:\}:'

echo -n ']}'
  1. Create a script to retrieve the desired data from the RabbitMQ queues, such as the following rabbitmq-items.sh script:
#!/bin/bash

queue="$1"
item="$2"

case "$item" in
  messages)
    sudo rabbitmqctl list_queues -p / | grep "^$queue\s" | awk '{ print $2 }'
    ;;
  consumers)
    sudo rabbitmqctl list_queues -p / | grep "^$queue\s" | awk '{ print $1 }'
    ;;
  *)
    echo "Unknown item: $item"
    exit 1
    ;;
esac
  1. Configure the Zabbix server to import the RabbitMQ template and associate it with the host running RabbitMQ.
  2. Customize the triggers within the template as desired to generate alerts based on queue size, message count, consumer count, and other relevant metrics.
  3. Verify that the triggers are firing correctly by monitoring the Zabbix dashboard and reviewing any generated notifications.
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-07-18 11:00:00 +0000

Seen: 9 times

Last updated: Aug 23 '22