sensu-plugins-rabbitmq 2.2.0 → 2.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff32df838a2e797f64a61cbe8252c90dbc4c9a0b
4
- data.tar.gz: 22809d71989e50eec3dd8adbe9250d1bab5d0599
3
+ metadata.gz: 4ffa72e143a7268373707912633c755281f22509
4
+ data.tar.gz: b8f03aa9b79d13d2cba68e43c1682bf39aa79bee
5
5
  SHA512:
6
- metadata.gz: 6fe85be96dc866d9c236252b3495272173b45818830fc7fd6086e9e7a5ddef51571dcfedd71fe2e92ee439d91a145eed6dedfb73ac281fecd95f59243ed1b3bc
7
- data.tar.gz: 2ccf9af3dd6ef5095ad8221d15639085c8e7cd59e3c8e6059f8c465dcfffc3f068c31cdd4cde9f711f7b8d10ee22a00294edb9c8e055ba9bb84aace88608197d
6
+ metadata.gz: e11e6b6cf34a8c0af5af7831250f07f29d662484fd598a525159a6aa01b24aa70202883121cfa7d5e752442c07172d3664ee0d6e974ec94d531760f8abf04003
7
+ data.tar.gz: 6824effe3ac2cff5c8e67867df1a0ddf850da3a749ec5ab872ccc7ee4440a16034a3b515c245a4d976f6a5594e813e62c4b4d68309de89bab54f736a2aae0233
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
  This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
5
 
6
6
  ## [Unreleased]
7
+ ### [2.3.0] - 2017-05-09
8
+ ### Added
9
+ - check-rabbitmq-node-usage.rb: added new check to look at rmq node resource useage. (@DvaBearqLoza)
10
+
7
11
  ### [2.2.0] - 2017-05-08
8
12
  ### Added
9
13
  - check-rabbitmq-queue.rb: Added --below feature to specify if value below threshold should generate alert (@alexpekurovsky)
@@ -118,7 +122,8 @@ NOTE: this release changes the option flags in check-rabbitmq-node-health.rb to
118
122
  - Remove copy paste errors in the Readme
119
123
  - Removed Rubygems require Ruby 1.8.7 backwards compatibility from all plugins
120
124
 
121
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/2.2.0...HEAD
125
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/2.3.0...HEAD
126
+ [2.3.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/2.2.0...2.3.0
122
127
  [2.2.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/2.1.0...2.2.0
123
128
  [2.1.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/2.0.0...2.1.0
124
129
  [2.0.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/1.3.0...2.0.0
data/README.md CHANGED
@@ -16,6 +16,7 @@
16
16
  * bin/check-rabbitmq-messages.rb
17
17
  * bin/check-rabbitmq-network-partitions.rb
18
18
  * bin/check-rabbitmq-node-health.rb
19
+ * bin/check-rabbitmq-node-usage.rb
19
20
  * bin/check-rabbitmq-queue-drain-time.rb
20
21
  * bin/check-rabbitmq-queue.rb
21
22
  * bin/check-rabbitmq-stomp-alive.rb
@@ -0,0 +1,304 @@
1
+ #!/usr/bin/env ruby -W0
2
+ # encoding: UTF-8
3
+ #
4
+ # RabbitMQ check node health plugin
5
+ # ===
6
+ #
7
+ # DESCRIPTION:
8
+ # This plugin checks if RabbitMQ server node is in a running state.
9
+ #
10
+ # The plugin is based on the RabbitMQ cluster node health plugin by Tim Smith
11
+ # Edited my Milos Dodic and Milos Buncic (2016/10/27)
12
+ #
13
+ # USAGE:
14
+ # "check-rabbitmq-node-usage.rb -w host --username user --password pass --type mem -m 50 -c 90"
15
+ #
16
+ # NOTES:
17
+ # Use of "type" is mandatory. The script will check only the specified type.
18
+ #
19
+ # PLATFORMS:
20
+ # Linux, Windows, BSD, Solaris
21
+ #
22
+ # DEPENDENCIES:
23
+ # RabbitMQ rabbitmq_management plugin
24
+ # gem: sensu-plugin
25
+ # gem: carrot-top
26
+ #
27
+ # LICENSE:
28
+ # Copyright 2012 Abhijith G <abhi@runa.com> and Runa Inc.
29
+ # Copyright 2014 Tim Smith <tim@cozy.co> and Cozy Services Ltd.
30
+ # Copyright 2015 Edward McLain <ed@edmclain.com> and Daxko, LLC.
31
+ #
32
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
33
+ # for details.
34
+
35
+ require 'sensu-plugin/check/cli'
36
+ require 'carrot-top'
37
+
38
+ # Main plugin class
39
+ class CheckRabbitMQNodeUsage < Sensu::Plugin::Check::CLI
40
+ option :host,
41
+ description: 'RabbitMQ host',
42
+ short: '-w',
43
+ long: '--host HOST',
44
+ default: 'localhost'
45
+
46
+ option :username,
47
+ description: 'RabbitMQ username',
48
+ short: '-u',
49
+ long: '--username USERNAME',
50
+ default: 'guest'
51
+
52
+ option :password,
53
+ description: 'RabbitMQ password',
54
+ short: '-p',
55
+ long: '--password PASSWORD',
56
+ default: 'guest'
57
+
58
+ option :port,
59
+ description: 'RabbitMQ API port',
60
+ short: '-P',
61
+ long: '--port PORT',
62
+ default: '15672'
63
+
64
+ option :ssl,
65
+ description: 'Enable SSL for connection to the API',
66
+ long: '--ssl',
67
+ boolean: true,
68
+ default: false
69
+
70
+ option :type,
71
+ description: 'Resource type',
72
+ required: true,
73
+ long: '--type TYPE',
74
+ in: %w(mem socket fd proc disk)
75
+
76
+ option :memwarn,
77
+ description: 'Warning % of mem usage vs high watermark',
78
+ short: '-m',
79
+ long: '--mwarn PERCENT',
80
+ proc: proc(&:to_f),
81
+ default: 80
82
+
83
+ option :memcrit,
84
+ description: 'Critical % of mem usage vs high watermark',
85
+ short: '-c',
86
+ long: '--mcrit PERCENT',
87
+ proc: proc(&:to_f),
88
+ default: 90
89
+
90
+ option :fdwarn,
91
+ description: 'Warning % of file descriptor usage vs high watermark',
92
+ short: '-f',
93
+ long: '--fwarn PERCENT',
94
+ proc: proc(&:to_f),
95
+ default: 80
96
+
97
+ option :fdcrit,
98
+ description: 'Critical % of file descriptor usage vs high watermark',
99
+ short: '-F',
100
+ long: '--fcrit PERCENT',
101
+ proc: proc(&:to_f),
102
+ default: 90
103
+
104
+ option :socketwarn,
105
+ description: 'Warning % of socket usage vs high watermark',
106
+ short: '-s',
107
+ long: '--swarn PERCENT',
108
+ proc: proc(&:to_f),
109
+ default: 80
110
+
111
+ option :socketcrit,
112
+ description: 'Critical % of socket usage vs high watermark',
113
+ short: '-S',
114
+ long: '--scrit PERCENT',
115
+ proc: proc(&:to_f),
116
+ default: 90
117
+
118
+ option :procwarn,
119
+ description: 'Warning % of proc usage vs high watermark',
120
+ short: '-e',
121
+ long: '--pwarn PERCENT',
122
+ proc: proc(&:to_f),
123
+ default: 80
124
+
125
+ option :proccrit,
126
+ description: 'Critical % of proc usage vs high watermark',
127
+ short: '-E',
128
+ long: '--pcrit PERCENT',
129
+ proc: proc(&:to_f),
130
+ default: 90
131
+
132
+ option :diskwarn,
133
+ description: 'Warning % of disk usage vs high watermark',
134
+ short: '-d',
135
+ long: '--dwarn PERCENT',
136
+ proc: proc(&:to_f),
137
+ default: 80
138
+
139
+ option :diskcrit,
140
+ description: 'Critical % of disk usage vs high watermark',
141
+ short: '-D',
142
+ long: '--dcrit PERCENT',
143
+ proc: proc(&:to_f),
144
+ default: 90
145
+
146
+ def run
147
+ res = node_healthy?
148
+
149
+ if res['status'] == 'ok'
150
+ ok res['message']
151
+ elsif res['status'] == 'warning'
152
+ warning res['message']
153
+ elsif res['status'] == 'critical'
154
+ critical res['message']
155
+ else
156
+ unknown res['message']
157
+ end
158
+ end
159
+
160
+ def node_healthy?
161
+ # Checks and shows usage (for the specified type only). Shows usage for ok status as well.
162
+ case config[:type]
163
+ when 'mem'
164
+ output = node_mem
165
+ when 'socket'
166
+ output = node_socket
167
+ when 'fd'
168
+ output = node_fd
169
+ when 'proc'
170
+ output = node_proc
171
+ when 'disk'
172
+ output = node_disk
173
+ end
174
+
175
+ { 'status' => output[:status], 'message' => output[:message] }
176
+ rescue => e
177
+ { 'status' => 'unknown', 'message' => e.message }
178
+ end
179
+
180
+ def node_mem
181
+ pmem = node_info[:pmem]
182
+
183
+ output = {}
184
+
185
+ if pmem.to_f >= config[:memcrit]
186
+ output[:message] = "Memory usage is critical: #{pmem}%"
187
+ output[:status] = 'critical'
188
+ elsif pmem.to_f >= config[:memwarn]
189
+ output[:message] = "Memory usage is at warning: #{pmem}%"
190
+ output[:status] = 'warning'
191
+ elsif pmem.to_f < config[:memwarn]
192
+ output[:message] = "Memory usage is at: #{pmem}%"
193
+ output[:status] = 'ok'
194
+ end
195
+
196
+ output
197
+ end
198
+
199
+ def node_socket
200
+ psocket = node_info[:psocket]
201
+
202
+ output = {}
203
+
204
+ if psocket.to_f >= config[:socketcrit]
205
+ output[:message] = "Socket usage is critical: #{psocket}%"
206
+ output[:status] = 'critical'
207
+ elsif psocket.to_f >= config[:socketwarn]
208
+ output[:message] = "Socket usage is at warning: #{psocket}%"
209
+ output[:status] = 'warning'
210
+ elsif psocket.to_f < config[:socketwarn]
211
+ output[:message] = "Socket usage is at: #{psocket}%"
212
+ output[:status] = 'ok'
213
+ end
214
+
215
+ output
216
+ end
217
+
218
+ def node_fd
219
+ pfd = node_info[:pfd]
220
+
221
+ output = {}
222
+
223
+ if pfd.to_f >= config[:fdcrit]
224
+ output[:message] = "File Descriptor usage is critical: #{pfd}%"
225
+ output[:status] = 'critical'
226
+ elsif pfd.to_f >= config[:fdwarn]
227
+ output[:message] = "File Descriptor usage is at warning: #{pfd}%"
228
+ output[:status] = 'warning'
229
+ elsif pfd.to_f < config[:fdwarn]
230
+ output[:message] = "File Descriptor usage is at: #{pfd}%"
231
+ output[:status] = 'ok'
232
+ end
233
+
234
+ output
235
+ end
236
+
237
+ def node_proc
238
+ pproc = node_info[:pproc]
239
+
240
+ output = {}
241
+
242
+ if pproc.to_f >= config[:proccrit]
243
+ output[:message] = "Proc usage is critical: #{pproc}%"
244
+ output[:status] = 'critical'
245
+ elsif pproc.to_f >= config[:procwarn]
246
+ output[:message] = "Proc usage is at warning: #{pproc}%"
247
+ output[:status] = 'warning'
248
+ elsif pproc.to_f < config[:procwarn]
249
+ output[:message] = "Proc usage is at: #{pproc}%"
250
+ output[:status] = 'ok'
251
+ end
252
+
253
+ output
254
+ end
255
+
256
+ def node_disk
257
+ pdisk = node_info[:pdisk]
258
+
259
+ output = {}
260
+
261
+ if pdisk.to_f >= config[:diskcrit]
262
+ output[:message] = "Disk usage is critical: #{pdisk}%"
263
+ output[:status] = 'critical'
264
+ elsif pdisk.to_f >= config[:diskwarn]
265
+ output[:message] = "Disk usage is at warning: #{pdisk}%"
266
+ output[:status] = 'warning'
267
+ elsif pdisk.to_f < config[:diskwarn]
268
+ output[:message] = "Disk usage is at: #{pdisk}%"
269
+ output[:status] = 'ok'
270
+ end
271
+
272
+ output
273
+ end
274
+
275
+ def node_info
276
+ # Parse the data
277
+ nodeinfo = rabbitmq_management.nodes[0]
278
+
279
+ output = {}
280
+
281
+ # Determine % memory consumed
282
+ output[:pmem] = format('%.2f', nodeinfo['mem_used'].fdiv(nodeinfo['mem_limit']) * 100)
283
+ # Determine % sockets consumed
284
+ output[:psocket] = format('%.2f', nodeinfo['sockets_used'].fdiv(nodeinfo['sockets_total']) * 100)
285
+ # Determine % file descriptors consumed
286
+ output[:pfd] = format('%.2f', nodeinfo['fd_used'].fdiv(nodeinfo['fd_total']) * 100)
287
+ # Determine % proc consumed
288
+ output[:pproc] = format('%.2f', nodeinfo['proc_used'].fdiv(nodeinfo['proc_total']) * 100)
289
+ # Determine % disk consumed
290
+ output[:pdisk] = format('%.2f', nodeinfo['disk_free_limit'].fdiv(nodeinfo['disk_free']) * 100)
291
+
292
+ output
293
+ end
294
+
295
+ def rabbitmq_management
296
+ CarrotTop.new(
297
+ host: config[:host],
298
+ port: config[:port],
299
+ user: config[:username],
300
+ password: config[:password],
301
+ ssl: config[:ssl]
302
+ )
303
+ end
304
+ end
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsRabbitMQ
2
2
  module Version
3
3
  MAJOR = 2
4
- MINOR = 2
4
+ MINOR = 3
5
5
  PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-rabbitmq
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
@@ -234,6 +234,7 @@ executables:
234
234
  - check-rabbitmq-messages.rb
235
235
  - check-rabbitmq-network-partitions.rb
236
236
  - check-rabbitmq-node-health.rb
237
+ - check-rabbitmq-node-usage.rb
237
238
  - check-rabbitmq-queue-drain-time.rb
238
239
  - check-rabbitmq-queue.rb
239
240
  - check-rabbitmq-stomp-alive.rb
@@ -252,6 +253,7 @@ files:
252
253
  - bin/check-rabbitmq-messages.rb
253
254
  - bin/check-rabbitmq-network-partitions.rb
254
255
  - bin/check-rabbitmq-node-health.rb
256
+ - bin/check-rabbitmq-node-usage.rb
255
257
  - bin/check-rabbitmq-queue-drain-time.rb
256
258
  - bin/check-rabbitmq-queue.rb
257
259
  - bin/check-rabbitmq-stomp-alive.rb