To establish a customized trigger for RabbitMQ queues in Zabbix, follow these steps:
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"
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 ']}'
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
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
Asked: 2021-07-18 11:00:00 +0000
Seen: 9 times
Last updated: Aug 23 '22
Why is awk -i inplace not functioning properly when used within a script?
Can you extract certain values located between columns in two separate csv files using Grep?
What is the Grep command that can be used to extract a section of the last line?
How can a decimal output be used in an if-else statement with an awk condition?
How can multiple patterns be counted in a file using AWK?
How can values in one file be replaced with values from another file in an efficient manner?
What is the process for utilizing sed and awk commands to extract patterns?
Can you use YQ to cut a list and save the modified version to a YAML file?