root / plugins / rabbitmq / rabbitmq_consumers @ 8589c6df
Historique | Voir | Annoter | Télécharger (2,2 ko)
| 1 |
#!/bin/sh |
|---|---|
| 2 |
# |
| 3 |
# Plugin to monitor the queues of a virtual_host in RabbitMQ |
| 4 |
# |
| 5 |
# Usage: Link or copy into /etc/munin/node.d/ |
| 6 |
# |
| 7 |
# Parameters |
| 8 |
# env.vhost <AMQ virtual host> |
| 9 |
# env.queue_warn <warning queuesize> |
| 10 |
# env.queue_crit <critical queuesize> |
| 11 |
# |
| 12 |
# Magic markers (optional - only used by munin-config and some |
| 13 |
# installation scripts): |
| 14 |
# |
| 15 |
#%# family=auto |
| 16 |
#%# capabilities=autoconf |
| 17 |
|
| 18 |
# If run with the "autoconf"-parameter, give our opinion on whether we |
| 19 |
# should be run on this system or not. This is optional, and only used by |
| 20 |
# munin-config. In the case of this plugin, we should most probably |
| 21 |
# always be included. |
| 22 |
|
| 23 |
if [ "$1" = "autoconf" ]; then |
| 24 |
echo yes |
| 25 |
exit 0 |
| 26 |
fi |
| 27 |
|
| 28 |
# If run with the "config"-parameter, give out information on how the |
| 29 |
# graphs should look. |
| 30 |
|
| 31 |
HOME=/tmp/ |
| 32 |
VHOST=${vhost:-"/"}
|
| 33 |
QUEUES=$(HOME=$HOME rabbitmqctl list_queues -p $VHOST name | \ |
| 34 |
grep -v '^Listing' | \ |
| 35 |
grep -v 'done\.$' | sed -e 's/[.=-]/_/g' ) |
| 36 |
|
| 37 |
if [ "$1" = "config" ]; then |
| 38 |
QUEUE_WARN=${queue_warn:-100}
|
| 39 |
QUEUE_CRIT=${queue_crit:-500}
|
| 40 |
|
| 41 |
# The host name this plugin is for. (Can be overridden to have |
| 42 |
# one machine answer for several) |
| 43 |
|
| 44 |
# The title of the graph |
| 45 |
echo "graph_title RabbitMQ $VHOST consumers" |
| 46 |
# Arguments to "rrdtool graph". In this case, tell it that the |
| 47 |
# lower limit of the graph is '0', and that 1k=1000 (not 1024) |
| 48 |
echo 'graph_args --base 1000 -l 0' |
| 49 |
# The Y-axis label |
| 50 |
echo 'graph_vlabel consumers' |
| 51 |
# We want Cur/Min/Avg/Max unscaled (i.e. 0.42 load instead of |
| 52 |
# 420 milliload) |
| 53 |
#echo 'graph_scale no' |
| 54 |
echo 'graph_category chat' |
| 55 |
|
| 56 |
for queue in $QUEUES; do |
| 57 |
echo "$queue.label $queue" |
| 58 |
echo "$queue.warning $QUEUE_WARN" |
| 59 |
echo "$queue.critical $QUEUE_CRIT" |
| 60 |
echo "$queue.info Active consumers for $queue" |
| 61 |
done |
| 62 |
|
| 63 |
echo 'graph_info Lists active consumers for a queue.' |
| 64 |
# Last, if run with the "config"-parameter, quit here (don't |
| 65 |
# display any data) |
| 66 |
exit 0 |
| 67 |
fi |
| 68 |
|
| 69 |
# If not run with any parameters at all (or only unknown ones), do the |
| 70 |
# real work - i.e. display the data. Almost always this will be |
| 71 |
# "value" subfield for every data field. |
| 72 |
|
| 73 |
HOME=$HOME rabbitmqctl list_queues -p $VHOST name consumers| \ |
| 74 |
grep -v "^Listing" | grep -v "done.$" | \ |
| 75 |
perl -nle'($q, $s) = split; $q =~ s/[.=-]/_/g; print("$q.value $s")'
|
