sensu-plugins-rabbitmq 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -0
- data/CHANGELOG.md +35 -0
- data/LICENSE +22 -0
- data/README.md +32 -0
- data/bin/check-rabbitmq-alive.rb +97 -0
- data/bin/check-rabbitmq-amqp-alive.rb +97 -0
- data/bin/check-rabbitmq-cluster-health.rb +124 -0
- data/bin/check-rabbitmq-consumers.rb +131 -0
- data/bin/check-rabbitmq-messages.rb +128 -0
- data/bin/check-rabbitmq-network-partitions.rb +82 -0
- data/bin/check-rabbitmq-node-health.rb +184 -0
- data/bin/check-rabbitmq-queue-drain-time.rb +129 -0
- data/bin/check-rabbitmq-queue.rb +117 -0
- data/bin/check-rabbitmq-stomp-alive.rb +109 -0
- data/bin/metrics-rabbitmq-overview.rb +142 -0
- data/bin/metrics-rabbitmq-queue.rb +108 -0
- data/lib/sensu-plugins-rabbitmq.rb +15 -0
- data/lib/sensu-plugins-rabbitmq/version.rb +28 -0
- metadata +284 -0
- metadata.gz.sig +1 -0
@@ -0,0 +1,117 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
#
|
4
|
+
# Check RabbitMQ Queue Messages
|
5
|
+
# ===
|
6
|
+
#
|
7
|
+
# DESCRIPTION:
|
8
|
+
# This plugin checks the number of messages queued on the RabbitMQ server in a specific queues
|
9
|
+
#
|
10
|
+
# PLATFORMS:
|
11
|
+
# Linux, BSD, Solaris
|
12
|
+
#
|
13
|
+
# DEPENDENCIES:
|
14
|
+
# RabbitMQ rabbitmq_management plugin
|
15
|
+
# gem: sensu-plugin
|
16
|
+
# gem: carrot-top
|
17
|
+
#
|
18
|
+
# LICENSE:
|
19
|
+
# Copyright 2012 Evan Hazlett <ejhazlett@gmail.com>
|
20
|
+
#
|
21
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
22
|
+
# for details.
|
23
|
+
|
24
|
+
require 'sensu-plugin/check/cli'
|
25
|
+
require 'socket'
|
26
|
+
require 'carrot-top'
|
27
|
+
|
28
|
+
# main plugin class
|
29
|
+
class CheckRabbitMQMessages < Sensu::Plugin::Check::CLI
|
30
|
+
option :host,
|
31
|
+
description: 'RabbitMQ management API host',
|
32
|
+
long: '--host HOST',
|
33
|
+
default: 'localhost'
|
34
|
+
|
35
|
+
option :port,
|
36
|
+
description: 'RabbitMQ management API port',
|
37
|
+
long: '--port PORT',
|
38
|
+
proc: proc(&:to_i),
|
39
|
+
default: 15_672
|
40
|
+
|
41
|
+
option :ssl,
|
42
|
+
description: 'Enable SSL for connection to the API',
|
43
|
+
long: '--ssl',
|
44
|
+
boolean: true,
|
45
|
+
default: false
|
46
|
+
|
47
|
+
option :user,
|
48
|
+
description: 'RabbitMQ management API user',
|
49
|
+
long: '--user USER',
|
50
|
+
default: 'guest'
|
51
|
+
|
52
|
+
option :password,
|
53
|
+
description: 'RabbitMQ management API password',
|
54
|
+
long: '--password PASSWORD',
|
55
|
+
default: 'guest'
|
56
|
+
|
57
|
+
option :queue,
|
58
|
+
description: 'RabbitMQ queue to monitor',
|
59
|
+
long: '--queue queue_names',
|
60
|
+
required: true,
|
61
|
+
proc: proc { |a| a.split(',') }
|
62
|
+
|
63
|
+
option :warn,
|
64
|
+
short: '-w NUM_MESSAGES',
|
65
|
+
long: '--warn NUM_MESSAGES',
|
66
|
+
description: 'WARNING message count threshold',
|
67
|
+
default: 250
|
68
|
+
|
69
|
+
option :critical,
|
70
|
+
short: '-c NUM_MESSAGES',
|
71
|
+
long: '--critical NUM_MESSAGES',
|
72
|
+
description: 'CRITICAL message count threshold',
|
73
|
+
default: 500
|
74
|
+
|
75
|
+
def acquire_rabbitmq_info
|
76
|
+
begin
|
77
|
+
rabbitmq_info = CarrotTop.new(
|
78
|
+
host: config[:host],
|
79
|
+
port: config[:port],
|
80
|
+
user: config[:user],
|
81
|
+
password: config[:password],
|
82
|
+
ssl: config[:ssl]
|
83
|
+
)
|
84
|
+
rescue
|
85
|
+
warning 'could not get rabbitmq info'
|
86
|
+
end
|
87
|
+
rabbitmq_info
|
88
|
+
end
|
89
|
+
|
90
|
+
def run
|
91
|
+
@crit = []
|
92
|
+
@warn = []
|
93
|
+
rabbitmq = acquire_rabbitmq_info
|
94
|
+
queues = rabbitmq.queues
|
95
|
+
config[:queue].each do |q|
|
96
|
+
unless queues.map { |hash| hash['name'] }.include? q
|
97
|
+
@warn << "Queue #{ q } not available"
|
98
|
+
next
|
99
|
+
end
|
100
|
+
queues.each do |queue|
|
101
|
+
next unless queue['name'] == q
|
102
|
+
total = queue['messages']
|
103
|
+
total = 0 if total.nil?
|
104
|
+
message "#{total}"
|
105
|
+
@crit << "#{ q }:#{ total }" if total > config[:critical].to_i
|
106
|
+
@warn << "#{ q }:#{ total }" if total > config[:warn].to_i
|
107
|
+
end
|
108
|
+
end
|
109
|
+
if @crit.empty? && @warn.empty?
|
110
|
+
ok
|
111
|
+
elsif !(@crit.empty?)
|
112
|
+
critical "critical: #{ @crit } warning: #{ @warn }"
|
113
|
+
elsif !(@warn.empty?)
|
114
|
+
warning "critical: #{ @crit } warning: #{ @warn }"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
#
|
4
|
+
# RabbitMQ check alive plugin
|
5
|
+
# ===
|
6
|
+
#
|
7
|
+
# DESCRIPTION:
|
8
|
+
# This plugin checks if RabbitMQ server is alive and responding to STOMP
|
9
|
+
# requests.
|
10
|
+
#
|
11
|
+
# Based on rabbitmq-amqp-alive by Milos Gajdos
|
12
|
+
#
|
13
|
+
# PLATFORMS:
|
14
|
+
# Linux, BSD, Solaris
|
15
|
+
#
|
16
|
+
# DEPENDENCIES:
|
17
|
+
# RabbitMQ rabbitmq_management plugin
|
18
|
+
# gem: sensu-plugin
|
19
|
+
# gem: stomp
|
20
|
+
#
|
21
|
+
# LICENSE:
|
22
|
+
# Copyright 2014 Adam Ashley
|
23
|
+
#
|
24
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
25
|
+
# for details.
|
26
|
+
|
27
|
+
require 'sensu-plugin/check/cli'
|
28
|
+
require 'stomp'
|
29
|
+
|
30
|
+
# main plugin class
|
31
|
+
class CheckRabbitStomp < Sensu::Plugin::Check::CLI
|
32
|
+
option :host,
|
33
|
+
description: 'RabbitMQ host',
|
34
|
+
short: '-w',
|
35
|
+
long: '--host HOST',
|
36
|
+
default: 'localhost'
|
37
|
+
|
38
|
+
option :username,
|
39
|
+
description: 'RabbitMQ username',
|
40
|
+
short: '-u',
|
41
|
+
long: '--username USERNAME',
|
42
|
+
default: 'guest'
|
43
|
+
|
44
|
+
option :password,
|
45
|
+
description: 'RabbitMQ password',
|
46
|
+
short: '-p',
|
47
|
+
long: '--password PASSWORD',
|
48
|
+
default: 'guest'
|
49
|
+
|
50
|
+
option :port,
|
51
|
+
description: 'RabbitMQ STOMP port',
|
52
|
+
short: '-P',
|
53
|
+
long: '--port PORT',
|
54
|
+
default: '61613'
|
55
|
+
|
56
|
+
option :ssl,
|
57
|
+
description: 'Enable SSL for connection to RabbitMQ',
|
58
|
+
long: '--ssl',
|
59
|
+
boolean: true,
|
60
|
+
default: false
|
61
|
+
|
62
|
+
option :queue,
|
63
|
+
description: 'Queue to post a message to and receive from',
|
64
|
+
short: '-q',
|
65
|
+
long: '--queue QUEUE',
|
66
|
+
default: 'aliveness-test'
|
67
|
+
|
68
|
+
def run
|
69
|
+
res = vhost_alive?
|
70
|
+
|
71
|
+
if res['status'] == 'ok'
|
72
|
+
ok res['message']
|
73
|
+
elsif res['status'] == 'critical'
|
74
|
+
critical res['message']
|
75
|
+
else
|
76
|
+
unknown res['message']
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def vhost_alive?
|
81
|
+
hash = {
|
82
|
+
hosts: [
|
83
|
+
{
|
84
|
+
login: config[:username],
|
85
|
+
passcode: config[:password],
|
86
|
+
host: config[:host],
|
87
|
+
port: config[:port],
|
88
|
+
ssl: config[:ssl]
|
89
|
+
}
|
90
|
+
],
|
91
|
+
reliable: false, # disable failover
|
92
|
+
connect_timeout: 10
|
93
|
+
}
|
94
|
+
|
95
|
+
begin
|
96
|
+
conn = Stomp::Client.new(hash)
|
97
|
+
conn.publish("/queue/#{config[:queue]}", 'STOMP Alive Test')
|
98
|
+
conn.subscribe("/queue/#{config[:queue]}") do |_msg|
|
99
|
+
end
|
100
|
+
{ 'status' => 'ok', 'message' => 'RabbitMQ server is alive' }
|
101
|
+
rescue Errno::ECONNREFUSED
|
102
|
+
{ 'status' => 'critical', 'message' => 'TCP connection refused' }
|
103
|
+
rescue Stomp::Error::BrokerException => e
|
104
|
+
{ 'status' => 'critical', 'message' => "Error from broker. Check auth details? #{e.message}" }
|
105
|
+
rescue => e
|
106
|
+
{ 'status' => 'unknown', 'message' => "#{e.class}: #{e.message}" }
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
#
|
4
|
+
# RabbitMQ Overview Metrics
|
5
|
+
# ===
|
6
|
+
#
|
7
|
+
# DESCRIPTION:
|
8
|
+
# RabbitMQ 'overview' stats are similar to what is shown on the main page
|
9
|
+
# of the rabbitmq_management web UI. Example:
|
10
|
+
#
|
11
|
+
# $ rabbitmq-queue-metrics.rb
|
12
|
+
# host.rabbitmq.queue_totals.messages.count 0 1344186404
|
13
|
+
# host.rabbitmq.queue_totals.messages.rate 0.0 1344186404
|
14
|
+
# host.rabbitmq.queue_totals.messages_unacknowledged.count 0 1344186404
|
15
|
+
# host.rabbitmq.queue_totals.messages_unacknowledged.rate 0.0 1344186404
|
16
|
+
# host.rabbitmq.queue_totals.messages_ready.count 0 1344186404
|
17
|
+
# host.rabbitmq.queue_totals.messages_ready.rate 0.0 1344186404
|
18
|
+
# host.rabbitmq.message_stats.publish.count 4605755 1344186404
|
19
|
+
# host.rabbitmq.message_stats.publish.rate 17.4130186829638 1344186404
|
20
|
+
# host.rabbitmq.message_stats.deliver_no_ack.count 6661111 1344186404
|
21
|
+
# host.rabbitmq.message_stats.deliver_no_ack.rate 24.6867565643405 1344186404
|
22
|
+
# host.rabbitmq.message_stats.deliver_get.count 6661111 1344186404
|
23
|
+
# host.rabbitmq.message_stats.deliver_get.rate 24.6867565643405 1344186404#
|
24
|
+
#
|
25
|
+
# PLATFORMS:
|
26
|
+
# Linux, BSD, Solaris
|
27
|
+
#
|
28
|
+
# DEPENDENCIES:
|
29
|
+
# RabbitMQ rabbitmq_management plugin
|
30
|
+
# gem: sensu-plugin
|
31
|
+
# gem: carrot-top
|
32
|
+
#
|
33
|
+
# LICENSE:
|
34
|
+
# Copyright 2012 Joe Miller - https://github.com/joemiller
|
35
|
+
#
|
36
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
37
|
+
# for details.
|
38
|
+
|
39
|
+
require 'sensu-plugin/metric/cli'
|
40
|
+
require 'socket'
|
41
|
+
require 'carrot-top'
|
42
|
+
|
43
|
+
# main plugin class
|
44
|
+
class RabbitMQMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
45
|
+
option :host,
|
46
|
+
description: 'RabbitMQ management API host',
|
47
|
+
long: '--host HOST',
|
48
|
+
default: 'localhost'
|
49
|
+
|
50
|
+
option :port,
|
51
|
+
description: 'RabbitMQ management API port',
|
52
|
+
long: '--port PORT',
|
53
|
+
proc: proc(&:to_i),
|
54
|
+
default: 15_672
|
55
|
+
|
56
|
+
option :user,
|
57
|
+
description: 'RabbitMQ management API user',
|
58
|
+
long: '--user USER',
|
59
|
+
default: 'guest'
|
60
|
+
|
61
|
+
option :password,
|
62
|
+
description: 'RabbitMQ management API password',
|
63
|
+
long: '--password PASSWORD',
|
64
|
+
default: 'guest'
|
65
|
+
|
66
|
+
option :scheme,
|
67
|
+
description: 'Metric naming scheme, text to prepend to $queue_name.$metric',
|
68
|
+
long: '--scheme SCHEME',
|
69
|
+
default: "#{Socket.gethostname}.rabbitmq"
|
70
|
+
|
71
|
+
option :ssl,
|
72
|
+
description: 'Enable SSL for connection to the API',
|
73
|
+
long: '--ssl',
|
74
|
+
boolean: true,
|
75
|
+
default: false
|
76
|
+
|
77
|
+
def acquire_rabbitmq_info
|
78
|
+
begin
|
79
|
+
rabbitmq_info = CarrotTop.new(
|
80
|
+
host: config[:host],
|
81
|
+
port: config[:port],
|
82
|
+
user: config[:user],
|
83
|
+
password: config[:password],
|
84
|
+
ssl: config[:ssl]
|
85
|
+
)
|
86
|
+
rescue
|
87
|
+
warning 'could not get rabbitmq info'
|
88
|
+
end
|
89
|
+
rabbitmq_info
|
90
|
+
end
|
91
|
+
|
92
|
+
def run #rubocop:disable all
|
93
|
+
timestamp = Time.now.to_i
|
94
|
+
|
95
|
+
rabbitmq = acquire_rabbitmq_info
|
96
|
+
overview = rabbitmq.overview
|
97
|
+
|
98
|
+
# overview['queue_totals']['messages']
|
99
|
+
if overview.key?('queue_totals') && !overview['queue_totals'].empty?
|
100
|
+
output "#{config[:scheme]}.queue_totals.messages.count", overview['queue_totals']['messages'], timestamp
|
101
|
+
output "#{config[:scheme]}.queue_totals.messages.rate", overview['queue_totals']['messages_details']['rate'], timestamp
|
102
|
+
|
103
|
+
# overview['queue_totals']['messages_unacknowledged']
|
104
|
+
output "#{config[:scheme]}.queue_totals.messages_unacknowledged.count", overview['queue_totals']['messages_unacknowledged'], timestamp
|
105
|
+
output "#{config[:scheme]}.queue_totals.messages_unacknowledged.rate", overview['queue_totals']['messages_unacknowledged_details']['rate'], timestamp
|
106
|
+
|
107
|
+
# overview['queue_totals']['messages_ready']
|
108
|
+
output "#{config[:scheme]}.queue_totals.messages_ready.count", overview['queue_totals']['messages_ready'], timestamp
|
109
|
+
output "#{config[:scheme]}.queue_totals.messages_ready.rate", overview['queue_totals']['messages_ready_details']['rate'], timestamp
|
110
|
+
end
|
111
|
+
|
112
|
+
if overview.key?('message_stats') && !overview['message_stats'].empty?
|
113
|
+
# overview['message_stats']['publish']
|
114
|
+
if overview['message_stats'].include?('publish')
|
115
|
+
output "#{config[:scheme]}.message_stats.publish.count", overview['message_stats']['publish'], timestamp
|
116
|
+
end
|
117
|
+
if overview['message_stats'].include?('publish_details') &&
|
118
|
+
overview['message_stats']['publish_details'].include?('rate')
|
119
|
+
output "#{config[:scheme]}.message_stats.publish.rate", overview['message_stats']['publish_details']['rate'], timestamp
|
120
|
+
end
|
121
|
+
|
122
|
+
# overview['message_stats']['deliver_no_ack']
|
123
|
+
if overview['message_stats'].include?('deliver_no_ack')
|
124
|
+
output "#{config[:scheme]}.message_stats.deliver_no_ack.count", overview['message_stats']['deliver_no_ack'], timestamp
|
125
|
+
end
|
126
|
+
if overview['message_stats'].include?('deliver_no_ack_details') &&
|
127
|
+
overview['message_stats']['deliver_no_ack_details'].include?('rate')
|
128
|
+
output "#{config[:scheme]}.message_stats.deliver_no_ack.rate", overview['message_stats']['deliver_no_ack_details']['rate'], timestamp
|
129
|
+
end
|
130
|
+
|
131
|
+
# overview['message_stats']['deliver_get']
|
132
|
+
if overview['message_stats'].include?('deliver_get')
|
133
|
+
output "#{config[:scheme]}.message_stats.deliver_get.count", overview['message_stats']['deliver_get'], timestamp
|
134
|
+
end
|
135
|
+
if overview['message_stats'].include?('deliver_get_details') &&
|
136
|
+
overview['message_stats']['deliver_get_details'].include?('rate')
|
137
|
+
output "#{config[:scheme]}.message_stats.deliver_get.rate", overview['message_stats']['deliver_get_details']['rate'], timestamp
|
138
|
+
end
|
139
|
+
end
|
140
|
+
ok
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
#
|
4
|
+
# RabbitMQ Queue Metrics
|
5
|
+
# ===
|
6
|
+
#
|
7
|
+
# DESCRIPTION:
|
8
|
+
# This plugin checks gathers the following per queue rabbitmq metrics:
|
9
|
+
# - message count
|
10
|
+
# - average egress rate
|
11
|
+
# - "drain time" metric, which is the time a queue will take to reach 0 based on the egress rate
|
12
|
+
# - consumer count
|
13
|
+
#
|
14
|
+
# PLATFORMS:
|
15
|
+
# Linux, BSD, Solaris
|
16
|
+
#
|
17
|
+
# DEPENDENCIES:
|
18
|
+
# RabbitMQ rabbitmq_management plugin
|
19
|
+
# gem: sensu-plugin
|
20
|
+
# gem: carrot-top
|
21
|
+
#
|
22
|
+
# LICENSE:
|
23
|
+
# Copyright 2011 Sonian, Inc <chefs@sonian.net>
|
24
|
+
# Copyright 2015 Tim Smith <tim@cozy.co> and Cozy Services Ltd.
|
25
|
+
#
|
26
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
27
|
+
# for details.
|
28
|
+
|
29
|
+
require 'sensu-plugin/metric/cli'
|
30
|
+
require 'socket'
|
31
|
+
require 'carrot-top'
|
32
|
+
|
33
|
+
# main plugin class
|
34
|
+
class RabbitMQMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
35
|
+
option :host,
|
36
|
+
description: 'RabbitMQ management API host',
|
37
|
+
long: '--host HOST',
|
38
|
+
default: 'localhost'
|
39
|
+
|
40
|
+
option :port,
|
41
|
+
description: 'RabbitMQ management API port',
|
42
|
+
long: '--port PORT',
|
43
|
+
proc: proc(&:to_i),
|
44
|
+
default: 15_672
|
45
|
+
|
46
|
+
option :user,
|
47
|
+
description: 'RabbitMQ management API user',
|
48
|
+
long: '--user USER',
|
49
|
+
default: 'guest'
|
50
|
+
|
51
|
+
option :password,
|
52
|
+
description: 'RabbitMQ management API password',
|
53
|
+
long: '--password PASSWORD',
|
54
|
+
default: 'guest'
|
55
|
+
|
56
|
+
option :scheme,
|
57
|
+
description: 'Metric naming scheme, text to prepend to $queue_name.$metric',
|
58
|
+
long: '--scheme SCHEME',
|
59
|
+
default: "#{Socket.gethostname}.rabbitmq"
|
60
|
+
|
61
|
+
option :filter,
|
62
|
+
description: 'Regular expression for filtering queues',
|
63
|
+
long: '--filter REGEX'
|
64
|
+
|
65
|
+
option :ssl,
|
66
|
+
description: 'Enable SSL for connection to the API',
|
67
|
+
long: '--ssl',
|
68
|
+
boolean: true,
|
69
|
+
default: false
|
70
|
+
|
71
|
+
def acquire_rabbitmq_queues
|
72
|
+
begin
|
73
|
+
rabbitmq_info = CarrotTop.new(
|
74
|
+
host: config[:host],
|
75
|
+
port: config[:port],
|
76
|
+
user: config[:user],
|
77
|
+
password: config[:password],
|
78
|
+
ssl: config[:ssl]
|
79
|
+
)
|
80
|
+
rescue
|
81
|
+
warning 'could not get rabbitmq queue info'
|
82
|
+
end
|
83
|
+
rabbitmq_info.queues
|
84
|
+
end
|
85
|
+
|
86
|
+
def run
|
87
|
+
timestamp = Time.now.to_i
|
88
|
+
acquire_rabbitmq_queues.each do |queue|
|
89
|
+
if config[:filter]
|
90
|
+
next unless queue['name'].match(config[:filter])
|
91
|
+
end
|
92
|
+
|
93
|
+
# calculate and output time till the queue is drained in drain metrics
|
94
|
+
drain_time = queue['messages'] / queue['backing_queue_status']['avg_egress_rate']
|
95
|
+
drain_time = 0 if drain_time.nan? # 0 rate with 0 messages is 0 time to drain
|
96
|
+
output([config[:scheme], queue['name'], 'drain_time'].join('.'), drain_time.to_i, timestamp)
|
97
|
+
|
98
|
+
%w(messages consumers).each do |metric|
|
99
|
+
output([config[:scheme], queue['name'], metric].join('.'), queue[metric], timestamp)
|
100
|
+
end
|
101
|
+
|
102
|
+
# fetch the average egress rate of the queue
|
103
|
+
rate = format('%.4f', queue['backing_queue_status']['avg_egress_rate'])
|
104
|
+
output([config[:scheme], queue['name'], 'avg_egress_rate'].join('.'), rate, timestamp)
|
105
|
+
end
|
106
|
+
ok
|
107
|
+
end
|
108
|
+
end
|