sensu-plugins-rabbitmq 5.0.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c311e72869b18722dcc6d4314f87ffb6e802558a1bbf2ea5d8bc177e3fdef55
4
- data.tar.gz: d3298c7f161eaea4ec281f6256cd00ed0545c5a85f946e784b919cd1b3e62712
3
+ metadata.gz: 82e03ad3782930ed8f79782b6e87218024e8e111a1a4e230b117b0eac38f7bac
4
+ data.tar.gz: 7f4d9a9c9abb26b6f9ca9a9f28cbf12bbeae7f11e783ae1a5c63647bcf1948d8
5
5
  SHA512:
6
- metadata.gz: 34901f8870f16e8b9a994886e82bba7cc27e4136589b7eab2b245597c69e51faf06149d259b3ce824086a893d8ce6e9197fa831f36d5d0b513855c8396f8ccb6
7
- data.tar.gz: c0bfb8b5466e96444c8b48893490ccb668a60a5e562a43c263e313c86160c65393e8cf604475136d937bf7164e1643e34ddadbb555364687c05afde3bdcbd8ef
6
+ metadata.gz: 5e47ea6fd59814ab95780c0d6290a9f9695124bc96d3dc8a06c3586ed8abe977223aed16839805d939d49f4c83fc7347a5dbcbc944a56ad80c3f35fa38f3840a
7
+ data.tar.gz: fdcdd2d46d097b84874a3bba58d2272a1ba7bc4f9d4feacf23e726dfba75dc458199a93dc967bcc0d798eaeed3bbd7e69e6d640a0786e80e0dd979a5e4a841bf
data/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [5.1.0] - 2018-05-15
9
+ ### Added
10
+ - check-rabbitmq-consumer-utilisation.rb: Added new check for consumer utilisation. Seeded from check-rabbitmq-consumers.rb. (@monkey670)
11
+
8
12
  ## [5.0.0] - 2018-05-02
9
13
  ### Breaking Changes
10
14
  - bump sensu-plugin version in dependencies to ~> 2.0. This should fix the issue where multiple versions of json (1.8.6 and 2.0.2) are being loaded, causing checks to fail (@mattdoller)
@@ -196,7 +200,8 @@ NOTE: this release changes the option flags in check-rabbitmq-node-health.rb to
196
200
  - Remove copy paste errors in the Readme
197
201
  - Removed Rubygems require Ruby 1.8.7 backwards compatibility from all plugins
198
202
 
199
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/5.0.0...HEAD
203
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/5.1.0...HEAD
204
+ [5.1.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/5.0.0...5.1.0
200
205
  [5.0.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/4.1.1...5.0.0
201
206
  [4.1.1]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/4.1.0...4.1.1
202
207
  [4.1.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/4.0.1...4.1.0
data/README.md CHANGED
@@ -13,6 +13,7 @@
13
13
  * bin/check-rabbitmq-amqp-alive.rb
14
14
  * bin/check-rabbitmq-cluster-health.rb
15
15
  * bin/check-rabbitmq-consumers.rb
16
+ * bin/check-rabbitmq-consumer-utilisation.rb
16
17
  * bin/check-rabbitmq-messages.rb
17
18
  * bin/check-rabbitmq-network-partitions.rb
18
19
  * bin/check-rabbitmq-node-health.rb
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Check RabbitMQ consumer utilisation
5
+ # ===
6
+ #
7
+ # DESCRIPTION:
8
+ # This plugin checks the consumer utilisation percentage.
9
+ # The fraction of time in which the queue is able to immediately deliver
10
+ # messages to consumer. If this number drops in percentage this may result
11
+ # in slower message delivery and indicate issues with the queue.
12
+ #
13
+ # Seeded from check-rabbitmq-consumers.rb
14
+ #
15
+ # PLATFORMS:
16
+ # Linux, BSD, Solaris
17
+ #
18
+ # DEPENDENCIES:
19
+ # RabbitMQ rabbitmq_management plugin
20
+ # gem: sensu-plugin
21
+ # gem: carrot-top
22
+ #
23
+ # LICENSE:
24
+ # Copyright 2014 Daniel Kerwin <d.kerwin@gini.net>
25
+ # Copyright 2014 Tim Smith <tim@cozy.co>
26
+ # Copyright 2018 Mike Murray <37150283+monkey670@users.noreply.github.com>
27
+ #
28
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
29
+ # for details.
30
+
31
+ require 'sensu-plugins-rabbitmq'
32
+ require 'sensu-plugins-rabbitmq/check'
33
+
34
+ # main plugin class
35
+ class CheckRabbitMQConsumerUtilisation < Sensu::Plugin::RabbitMQ::Check
36
+ option :regex,
37
+ description: 'Treat the --queue flag as a regular expression.',
38
+ long: '--regex',
39
+ boolean: true,
40
+ default: false
41
+
42
+ option :queue,
43
+ description: 'Comma separated list of RabbitMQ queues to monitor.',
44
+ long: '--queue queue_name'
45
+
46
+ option :exclude,
47
+ description: 'Comma separated list of RabbitMQ queues to NOT monitor. All others will be monitored.',
48
+ long: '--exclude queue_name'
49
+
50
+ option :warn,
51
+ short: '-w CONSUMER_UTILISATION',
52
+ long: '--warn CONSUMER_UTILISATION',
53
+ proc: proc(&:to_f),
54
+ description: 'WARNING consumer utilisation threshold',
55
+ default: 0.9
56
+
57
+ option :critical,
58
+ short: '-c CONSUMER_UTILISATION',
59
+ long: '--critical CONSUMER_UTILISATION',
60
+ description: 'CRITICAL consumer utilisation threshold',
61
+ proc: proc(&:to_f),
62
+ default: 0.5
63
+
64
+ def queue_list_builder(input)
65
+ return [] if input.nil?
66
+ return [input] if config[:regex]
67
+ input.split(',')
68
+ end
69
+
70
+ def return_condition(missing, critical, warning)
71
+ if critical.count > 0 || missing.count > 0
72
+ message = []
73
+ message << "Queues in critical state: #{critical.join(', ')}. " if critical.count > 0
74
+ message << "Queues missing: #{missing.join(', ')}" if missing.count > 0
75
+ critical(message.join("\n"))
76
+ elsif warning.count > 0
77
+ warning("Queues in warning state: #{warning.join(', ')}")
78
+ else
79
+ ok
80
+ end
81
+ end
82
+
83
+ def run
84
+ # create arrays to hold failures
85
+ queue_list = queue_list_builder(config[:queue])
86
+ exclude_list = queue_list_builder(config[:exclude])
87
+ missing = if config[:regex]
88
+ []
89
+ else
90
+ queue_list || []
91
+ end
92
+ critical = []
93
+ warn = []
94
+ rabbitmq = acquire_rabbitmq_info
95
+ begin
96
+ rabbitmq.queues.each do |queue|
97
+ # if specific queues were passed only monitor those.
98
+ # if specific queues to exclude were passed then skip those
99
+ if config[:regex]
100
+ if config[:queue] && config[:exclude]
101
+ next unless queue['name'] =~ /#{queue_list.first}/ && queue['name'] !~ /#{exclude_list.first}/
102
+ else
103
+ next unless queue['name'] =~ /#{queue_list.first}/
104
+ end
105
+ elsif config[:queue]
106
+ next unless queue_list.include?(queue['name'])
107
+ elsif config[:exclude]
108
+ next if exclude_list.include?(queue['name'])
109
+ end
110
+ missing.delete(queue['name'])
111
+ consumer_util = queue['consumer_utilisation'] || 0
112
+ critical.push("#{queue['name']}:#{consumer_util.round(2) * 100}%") if consumer_util <= config[:critical]
113
+ warn.push("#{queue['name']}:#{consumer_util.round(2) * 100}%") if consumer_util <= config[:warn]
114
+ end
115
+ rescue StandardError
116
+ critical 'Could not find any queue, check rabbitmq server'
117
+ end
118
+ return_condition(missing, critical, warn)
119
+ end
120
+ end
@@ -3,7 +3,7 @@
3
3
  module SensuPluginsRabbitMQ
4
4
  module Version
5
5
  MAJOR = 5
6
- MINOR = 0
6
+ MINOR = 1
7
7
  PATCH = 0
8
8
 
9
9
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-rabbitmq
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-02 00:00:00.000000000 Z
11
+ date: 2018-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -258,6 +258,7 @@ executables:
258
258
  - check-rabbitmq-alive.rb
259
259
  - check-rabbitmq-amqp-alive.rb
260
260
  - check-rabbitmq-cluster-health.rb
261
+ - check-rabbitmq-consumer-utilisation.rb
261
262
  - check-rabbitmq-consumers.rb
262
263
  - check-rabbitmq-messages.rb
263
264
  - check-rabbitmq-network-partitions.rb
@@ -279,6 +280,7 @@ files:
279
280
  - bin/check-rabbitmq-alive.rb
280
281
  - bin/check-rabbitmq-amqp-alive.rb
281
282
  - bin/check-rabbitmq-cluster-health.rb
283
+ - bin/check-rabbitmq-consumer-utilisation.rb
282
284
  - bin/check-rabbitmq-consumers.rb
283
285
  - bin/check-rabbitmq-messages.rb
284
286
  - bin/check-rabbitmq-network-partitions.rb