root / plugins / rabbitmq / rabbitmq_messages_uncommitted @ 17f78427
Historique | Voir | Annoter | Télécharger (2,24 ko)
| 1 | 5f8bf7e7 | Lx Yu | #!/bin/sh |
|---|---|---|---|
| 2 | 17f78427 | Lars Kruse | # |
| 3 | 5f8bf7e7 | Lx Yu | # 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 | fba800ae | Veres Lajos | # If run with the "autoconf"-parameter, give our opinion on whether we |
| 19 | 8589c6df | klemens | # should be run on this system or not. This is optional, and only used by |
| 20 | 5f8bf7e7 | Lx Yu | # 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 | 17f78427 | Lars Kruse | # graphs should look. |
| 30 | 5f8bf7e7 | Lx Yu | |
| 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 | 17f78427 | Lars Kruse | |
| 37 | 5f8bf7e7 | Lx Yu | if [ "$1" = "config" ]; then |
| 38 | QUEUE_WARN=${queue_warn:-10000}
|
||
| 39 | QUEUE_CRIT=${queue_crit:-20000}
|
||
| 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 Uncommitted Messages" |
||
| 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 uncommitted' |
||
| 51 | # We want Cur/Min/Avg/Max unscaled (i.e. 0.42 load instead of |
||
| 52 | # 420 milliload) |
||
| 53 | #echo 'graph_scale no' |
||
| 54 | 0104c6d4 | dipohl | echo 'graph_category chat' |
| 55 | 5f8bf7e7 | Lx Yu | |
| 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 Uncommitted messages for $queue" |
||
| 61 | done |
||
| 62 | |||
| 63 | echo 'graph_info Lists how many messages are in each 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_channels -p $VHOST name messages_uncommitted | \ |
||
| 74 | grep -v "^Listing" | grep -v "done.$" | \ |
||
| 75 | perl -nle'($q, $s) = split; $q =~ s/[.=-]/_/g; print("$q.value $s")' |
