Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.