Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / rabbitmq / rabbitmq_connections @ 17f78427

Historique | Voir | Annoter | Télécharger (2,31 ko)

1
#!/bin/sh
2

    
3
: << =cut
4

    
5
=head1 NAME
6

    
7
rabbitmq_connections - monitor the number of connections to RabbitMQ
8

    
9
=head1 CONFIGURATION
10

    
11
You will need to add configuration to
12
/etc/munin/plugin-conf.d/rabbitmq_connection.conf for this plugin to
13
work.
14

    
15
=over 2
16

    
17
=item C<user>
18

    
19
Required. Valid choices are C<rabbitmq> and C<root>. This is required
20
by C<rabbitmqctl>.
21

    
22
=item C<env.conn_warn>
23

    
24
Optional, default value is 500
25

    
26
=item C<env.conn_crit>
27

    
28
Optional, default value is 1000
29

    
30
=back
31

    
32
=head2 EXAMPLE CONFIGURATION
33

    
34
  [rabbitmq_connections]
35
    user rabbitmq
36
    env.conn_warn 512
37
    env.conn_crit 1024
38

    
39
=head1 MAGIC MARKERS
40

    
41
  #%# family=contrib
42

    
43
=cut
44

    
45
case $(whoami) in
46
    rabbitmq|root)
47
        ;;
48
    *)
49
        echo 'Error: Plugin requires "user" to be set in plugin configuration.' >&2
50
        echo 'See "munindoc rabbitmq_connections" for more information'  >&2
51
        exit 1
52
        ;;
53
esac
54

    
55
# If run with the "config"-parameter, give out information on how the
56
# graphs should look.
57

    
58
if [ "$1" = "config" ]; then
59
        CONN_WARN=${conn_warn:-500}
60
        CONN_CRIT=${conn_crit:-1000}
61

    
62
	# The host name this plugin is for. (Can be overridden to have
63
	# one machine answer for several)
64

    
65
	# The title of the graph
66
	echo 'graph_title RabbitMQ connections'
67
	# Arguments to "rrdtool graph". In this case, tell it that the
68
	# lower limit of the graph is '0', and that 1k=1000 (not 1024)
69
	echo 'graph_args --base 1000 -l 0'
70
	# The Y-axis label
71
	echo 'graph_vlabel connections'
72
	# We want Cur/Min/Avg/Max unscaled (i.e. 0.42 load instead of
73
	# 420 milliload)
74
	#echo 'graph_scale no'
75
	echo 'graph_category chat'
76

    
77
	echo "connections.label Connections"
78
	echo "connections.warning $CONN_WARN"
79
	echo "connections.critical $CONN_CRIT"
80
	echo "connections.info Number of active connections"
81

    
82
	echo 'graph_info Shows the number of connections to RabbitMQ'
83
	# Last, if run with the "config"-parameter, quit here (don't
84
	# display any data)
85
	exit 0
86
fi
87

    
88
# If not run with any parameters at all (or only unknown ones), do the
89
# real work - i.e. display the data. Almost always this will be
90
# "value" subfield for every data field.
91

    
92
if command -v rabbitmqctl >/dev/null 2>&1; then
93
    connections=$(HOME=/tmp rabbitmqctl list_connections state | grep -c running)
94
else
95
    echo "$0: Could not run rabbitmqctl" >&2
96
    connections=U
97
fi
98

    
99
printf "connections.value %s\n" "$connections"