riemann-rabbitmq 0.1.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
- data/LICENSE +21 -0
- data/README.md +10 -0
- data/bin/riemann-rabbitmq +268 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cb0770adc04abda0c79b2ba8e7a4c7ade541e6f2
|
4
|
+
data.tar.gz: e13a96780fd69ded7848da9b42e97cae66fe211f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e2a74fa00bc2f465151b416ec41da3ecd11d00c0dc02ee015ae7c44708516c6fa68aead56257f970aa9bb2e64ed1c68d73703f976707f1c950ec5f953ab853be
|
7
|
+
data.tar.gz: b08dc16a4f0005f7ed1aba9d9b1be5a89141975767495915cf1fcddb5d320e693a1d074d490f2638403cfae35bdb9535f3d9b4e26185f535946a24992f8b54ef
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011 Kyle Kingsbury
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,268 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'riemann/tools'
|
4
|
+
|
5
|
+
class Riemann::Tools::Rabbitmq
|
6
|
+
include Riemann::Tools
|
7
|
+
|
8
|
+
require 'faraday'
|
9
|
+
require 'json'
|
10
|
+
require 'uri'
|
11
|
+
|
12
|
+
|
13
|
+
opt :read_timeout, 'Faraday read timeout', type: :int, default: 2
|
14
|
+
opt :open_timeout, 'Faraday open timeout', type: :int, default: 1
|
15
|
+
|
16
|
+
opt :monitor_user, 'RabbitMQ monitoring user', type: :string
|
17
|
+
opt :monitor_pass, 'RabbitMQ monitoring user password', type: :string
|
18
|
+
opt :monitor_port, 'RabbitMQ monitoring port', type: :int, default: 15672
|
19
|
+
opt :monitor_host, 'RabbitMQ monitoring host', type: :string, default: "localhost"
|
20
|
+
opt :monitor_use_tls, 'RabbitMQ use tls', type: :bool, default: false
|
21
|
+
|
22
|
+
opt :max_queue_size, "max number of items in a queue that is acceptable", type: :int, default: 1_000_000
|
23
|
+
opt :ignore_max_size_queues, "A regular expression to match queues that shouldn't be size-checked", type: :string
|
24
|
+
|
25
|
+
opt :node, "Specify a node to monitor", type: :strings
|
26
|
+
|
27
|
+
def base_url
|
28
|
+
protocol = "http"
|
29
|
+
if (options[:monitor_use_tls]) && (options[:monitor_use_tls]==true)
|
30
|
+
protocol = "https"
|
31
|
+
end
|
32
|
+
"#{protocol}://#{options[:monitor_user]}:#{options[:monitor_pass]}@#{options[:monitor_host]}:#{options[:monitor_port]}/api"
|
33
|
+
end
|
34
|
+
|
35
|
+
def overview_url
|
36
|
+
"#{base_url}/overview"
|
37
|
+
end
|
38
|
+
|
39
|
+
def node_url(n)
|
40
|
+
"#{base_url}/nodes/#{n}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def queues_url
|
44
|
+
"#{base_url}/queues"
|
45
|
+
end
|
46
|
+
|
47
|
+
def event_host
|
48
|
+
if options[:event_host]
|
49
|
+
return options[:event_host]
|
50
|
+
else
|
51
|
+
return options[:monitor_host]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def safe_get(uri, event_host)
|
56
|
+
# Handle connection timeouts
|
57
|
+
response = nil
|
58
|
+
begin
|
59
|
+
connection = Faraday.new(uri)
|
60
|
+
response = connection.get do |req|
|
61
|
+
req.options[:timeout] = options[:read_timeout]
|
62
|
+
req.options[:open_timeout] = options[:open_timeout]
|
63
|
+
end
|
64
|
+
report(:host => event_host,
|
65
|
+
:service => "rabbitmq monitoring",
|
66
|
+
:state => 'ok',
|
67
|
+
:description => "Monitoring operational"
|
68
|
+
)
|
69
|
+
rescue => e
|
70
|
+
report(:host => event_host,
|
71
|
+
:service => "rabbitmq monitoring",
|
72
|
+
:state => "critical",
|
73
|
+
:description => "HTTP connection error: #{e.class} - #{e.message}"
|
74
|
+
)
|
75
|
+
end
|
76
|
+
response
|
77
|
+
end
|
78
|
+
|
79
|
+
def check_queues
|
80
|
+
response = safe_get(queues_url, event_host)
|
81
|
+
max_size_check_filter = if options[:ignore_max_size_queues]
|
82
|
+
Regexp.new(options[:ignore_max_size_queues])
|
83
|
+
else
|
84
|
+
nil
|
85
|
+
end
|
86
|
+
|
87
|
+
return if response.nil?
|
88
|
+
|
89
|
+
json = JSON.parse(response.body)
|
90
|
+
|
91
|
+
if response.status != 200
|
92
|
+
report(:host => event_host,
|
93
|
+
:service => "rabbitmq.queue",
|
94
|
+
:state => "critical",
|
95
|
+
:description => "HTTP connection error to /api/queues: #{response.status} - #{response.body}"
|
96
|
+
)
|
97
|
+
else
|
98
|
+
report(:host => event_host,
|
99
|
+
:service => "rabbitmq.queue",
|
100
|
+
:state => "ok",
|
101
|
+
:description => "HTTP connection ok"
|
102
|
+
)
|
103
|
+
|
104
|
+
json = JSON.parse(response.body)
|
105
|
+
|
106
|
+
json.each do |queue|
|
107
|
+
svc = "rabbitmq.queue.#{queue['vhost']}.#{queue['name']}"
|
108
|
+
errs = []
|
109
|
+
|
110
|
+
if queue['messages_ready']!=nil and queue['messages_ready'] > 0 and queue['consumers'] == 0
|
111
|
+
errs << "Queue has jobs but no consumers"
|
112
|
+
end
|
113
|
+
|
114
|
+
if (max_size_check_filter.nil? or queue['name'] !~ max_size_check_filter) and queue['messages_ready']!=nil and queue['messages_ready'] > options[:max_queue_size]
|
115
|
+
errs << "Queue has #{queue['messages_ready']} jobs"
|
116
|
+
end
|
117
|
+
|
118
|
+
if errs.empty?
|
119
|
+
report(:host => event_host,
|
120
|
+
:service => svc,
|
121
|
+
:state => "ok",
|
122
|
+
:description => "Queue is looking good"
|
123
|
+
)
|
124
|
+
else
|
125
|
+
report(:host => event_host,
|
126
|
+
:service => svc,
|
127
|
+
:state => "critical",
|
128
|
+
:description => errs.join("; ")
|
129
|
+
)
|
130
|
+
end
|
131
|
+
|
132
|
+
stats = (queue['message_stats'] || {}).merge(
|
133
|
+
'messages' => queue['messages'],
|
134
|
+
'messages_details' => queue['messages_details'],
|
135
|
+
'messages_ready' => queue['messages_ready'],
|
136
|
+
'messages_ready_details' => queue['messages_ready_details'],
|
137
|
+
'messages_unacknowledged' => queue['messages_unacknowledged'],
|
138
|
+
'messages_unacknowledged_details' => queue['messages_unacknowledged_details'],
|
139
|
+
'consumers' => queue['consumers'],
|
140
|
+
'memory' => queue['memory'],
|
141
|
+
)
|
142
|
+
|
143
|
+
stats.each_pair do |k,v|
|
144
|
+
service = "#{svc}.#{k}"
|
145
|
+
if k =~ /details$/ and v!=nil
|
146
|
+
metric = v['rate']
|
147
|
+
else
|
148
|
+
metric = v
|
149
|
+
end
|
150
|
+
|
151
|
+
# TODO: Set state via thresholds which can be configured
|
152
|
+
|
153
|
+
report(:host => event_host,
|
154
|
+
:service => service,
|
155
|
+
:metric => metric,
|
156
|
+
:description => "RabbitMQ monitor"
|
157
|
+
)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def check_overview
|
164
|
+
uri = URI(overview_url)
|
165
|
+
response = safe_get(uri, event_host)
|
166
|
+
|
167
|
+
return if response.nil?
|
168
|
+
|
169
|
+
json = JSON.parse(response.body)
|
170
|
+
|
171
|
+
if response.status != 200
|
172
|
+
report(:host => event_host,
|
173
|
+
:service => "rabbitmq",
|
174
|
+
:state => "critical",
|
175
|
+
:description => "HTTP connection error: #{response.status} - #{response.body}"
|
176
|
+
)
|
177
|
+
else
|
178
|
+
report(:host => event_host,
|
179
|
+
:service => "rabbitmq monitoring",
|
180
|
+
:state => "ok",
|
181
|
+
:description => "HTTP connection ok"
|
182
|
+
)
|
183
|
+
|
184
|
+
%w( message_stats queue_totals object_totals ).each do |stat|
|
185
|
+
# NOTE / BUG ?
|
186
|
+
# Brand new servers can have blank message stats. Is this ok?
|
187
|
+
# I can't decide.
|
188
|
+
next if json[stat].empty?
|
189
|
+
json[stat].each_pair do |k,v|
|
190
|
+
service = "rabbitmq.#{stat}.#{k}"
|
191
|
+
if k =~ /details$/
|
192
|
+
metric = v['rate']
|
193
|
+
else
|
194
|
+
metric = v
|
195
|
+
end
|
196
|
+
|
197
|
+
# TODO: Set state via thresholds which can be configured
|
198
|
+
|
199
|
+
report(:host => event_host,
|
200
|
+
:service => service,
|
201
|
+
:metric => metric,
|
202
|
+
:description => "RabbitMQ monitor"
|
203
|
+
)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def check_node
|
210
|
+
opts[:node].each do |n|
|
211
|
+
uri = URI(node_url(n))
|
212
|
+
response = safe_get(uri, event_host)
|
213
|
+
|
214
|
+
return if response.nil?
|
215
|
+
|
216
|
+
if response.status != 200
|
217
|
+
if response.status == 404
|
218
|
+
report(:host => event_host,
|
219
|
+
:service => "rabbitmq.node.#{n}",
|
220
|
+
:state => "critical",
|
221
|
+
:description => "Node was not found in the cluster"
|
222
|
+
)
|
223
|
+
else
|
224
|
+
report(:host => event_host,
|
225
|
+
:service => "rabbitmq.node.#{n}",
|
226
|
+
:state => "critical",
|
227
|
+
:description => "HTTP error: #{response.status} - #{response.body}"
|
228
|
+
)
|
229
|
+
end
|
230
|
+
return
|
231
|
+
end
|
232
|
+
|
233
|
+
json = JSON.parse(response.body)
|
234
|
+
|
235
|
+
if json['mem_alarm']
|
236
|
+
report(:host => event_host,
|
237
|
+
:service => "rabbitmq.node.#{n}",
|
238
|
+
:state => "critical",
|
239
|
+
:description => "Memory alarm has triggered; job submission throttled"
|
240
|
+
)
|
241
|
+
return
|
242
|
+
end
|
243
|
+
|
244
|
+
if json['disk_free_alarm']
|
245
|
+
report(:host => event_host,
|
246
|
+
:service => "rabbitmq.node.#{n}",
|
247
|
+
:state => "critical",
|
248
|
+
:description => "Disk free alarm has triggered; job submission throttled"
|
249
|
+
)
|
250
|
+
return
|
251
|
+
end
|
252
|
+
|
253
|
+
report(:host => event_host,
|
254
|
+
:service => "rabbitmq.node.#{n}",
|
255
|
+
:state => "ok",
|
256
|
+
:description => "Node looks OK to me"
|
257
|
+
)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
def tick
|
262
|
+
check_overview
|
263
|
+
check_node if opts[:node]
|
264
|
+
check_queues
|
265
|
+
end
|
266
|
+
end
|
267
|
+
Riemann::Tools::Rabbitmq.run
|
268
|
+
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: riemann-rabbitmq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gavin Sandie
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: riemann-tools
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.8.5
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.8.5
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email: beach@vicecity.co.uk
|
57
|
+
executables:
|
58
|
+
- riemann-rabbitmq
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- LICENSE
|
63
|
+
- README.md
|
64
|
+
- bin/riemann-rabbitmq
|
65
|
+
homepage: https://github.com/riemann/riemann-rabbitmq
|
66
|
+
licenses: []
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.8.7
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project: riemann-rabbitmq
|
84
|
+
rubygems_version: 2.4.5
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Submits rabbitmq stats to riemann.
|
88
|
+
test_files: []
|