sensu-plugins-rabbitmq 5.1.0 → 5.2.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
  SHA256:
3
- metadata.gz: 82e03ad3782930ed8f79782b6e87218024e8e111a1a4e230b117b0eac38f7bac
4
- data.tar.gz: 7f4d9a9c9abb26b6f9ca9a9f28cbf12bbeae7f11e783ae1a5c63647bcf1948d8
3
+ metadata.gz: ed655870ff4e4af3f14482fe4a6998981a6c8112109ce5e8027b39c41d5debae
4
+ data.tar.gz: 444be0ee77dc6bf542b3a9659dbc999640ab3f3426b9ce7e5ead723ce87723e8
5
5
  SHA512:
6
- metadata.gz: 5e47ea6fd59814ab95780c0d6290a9f9695124bc96d3dc8a06c3586ed8abe977223aed16839805d939d49f4c83fc7347a5dbcbc944a56ad80c3f35fa38f3840a
7
- data.tar.gz: fdcdd2d46d097b84874a3bba58d2272a1ba7bc4f9d4feacf23e726dfba75dc458199a93dc967bcc0d798eaeed3bbd7e69e6d640a0786e80e0dd979a5e4a841bf
6
+ metadata.gz: a4e33b8c10125c3b023a18dc232974bae0f43626f3d37b6b53d9864362dd6bec691290930bcf404ed7f195f520c0acac0fbb6d85d9941a1c50b6fafcb491b736
7
+ data.tar.gz: ea28d295f7602113584830cb06ea4efc7dbf360fc4aa6bc32342638b043fa70f1f511a6488fb254956a9f2fae970848dd32d53f718e11472968f950171eae3c5
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.2.0] - 2018-05-16
9
+ ### Changed
10
+ - check-rabbitmq-consumers.rb: Backport recommended code updates. Add consumer count to warn/critical message. (@monkey670)
11
+
8
12
  ## [5.1.0] - 2018-05-15
9
13
  ### Added
10
14
  - check-rabbitmq-consumer-utilisation.rb: Added new check for consumer utilisation. Seeded from check-rabbitmq-consumers.rb. (@monkey670)
@@ -200,7 +204,8 @@ NOTE: this release changes the option flags in check-rabbitmq-node-health.rb to
200
204
  - Remove copy paste errors in the Readme
201
205
  - Removed Rubygems require Ruby 1.8.7 backwards compatibility from all plugins
202
206
 
203
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/5.1.0...HEAD
207
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/5.2.0...HEAD
208
+ [5.2.0]:https://github.com/sensu-plugins/sensu-plugins-rabbitmq/\compare/5.1.0...5.2.0
204
209
  [5.1.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/5.0.0...5.1.0
205
210
  [5.0.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/4.1.1...5.0.0
206
211
  [4.1.1]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/4.1.0...4.1.1
@@ -61,12 +61,6 @@ class CheckRabbitMQConsumerUtilisation < Sensu::Plugin::RabbitMQ::Check
61
61
  proc: proc(&:to_f),
62
62
  default: 0.5
63
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
64
  def return_condition(missing, critical, warning)
71
65
  if critical.count > 0 || missing.count > 0
72
66
  message = []
@@ -18,58 +18,29 @@
18
18
  # LICENSE:
19
19
  # Copyright 2014 Daniel Kerwin <d.kerwin@gini.net>
20
20
  # Copyright 2014 Tim Smith <tim@cozy.co>
21
+ # Copyright 2018 Mike Murray <37150283+monkey670@users.noreply.github.com>
21
22
  #
22
23
  # Released under the same terms as Sensu (the MIT license); see LICENSE
23
24
  # for details.
24
25
 
25
- require 'sensu-plugin/check/cli'
26
- require 'carrot-top'
27
- require 'inifile'
26
+ require 'sensu-plugins-rabbitmq'
27
+ require 'sensu-plugins-rabbitmq/check'
28
28
 
29
29
  # main plugin class
30
- class CheckRabbitMQConsumers < Sensu::Plugin::Check::CLI
31
- option :host,
32
- description: 'RabbitMQ management API host',
33
- long: '--host HOST',
34
- default: 'localhost'
35
-
36
- option :port,
37
- description: 'RabbitMQ management API port',
38
- long: '--port PORT',
39
- proc: proc(&:to_i),
40
- default: 15_672
41
-
42
- option :ssl,
43
- description: 'Enable SSL for connection to the API',
44
- long: '--ssl',
30
+ class CheckRabbitMQConsumers < Sensu::Plugin::RabbitMQ::Check
31
+ option :regex,
32
+ description: 'Treat the --queue flag as a regular expression.',
33
+ long: '--regex',
45
34
  boolean: true,
46
35
  default: false
47
36
 
48
- option :username,
49
- description: 'RabbitMQ management API user',
50
- long: '--username USER',
51
- default: 'guest'
52
-
53
- option :password,
54
- description: 'RabbitMQ management API password',
55
- long: '--password PASSWORD',
56
- default: 'guest'
57
-
58
37
  option :queue,
59
38
  description: 'Comma separated list of RabbitMQ queues to monitor.',
60
- long: '--queue queue_name',
61
- proc: proc { |q| q.split(',') }
39
+ long: '--queue queue_name'
62
40
 
63
41
  option :exclude,
64
42
  description: 'Comma separated list of RabbitMQ queues to NOT monitor. All others will be monitored.',
65
- long: '--exclude queue_name',
66
- proc: proc { |q| q.split(',') }
67
-
68
- option :regex,
69
- description: 'Treat the --queue flag as a regular expression.',
70
- long: '--regex',
71
- boolean: true,
72
- default: false
43
+ long: '--exclude queue_name'
73
44
 
74
45
  option :warn,
75
46
  short: '-w NUM_CONSUMERS',
@@ -85,43 +56,13 @@ class CheckRabbitMQConsumers < Sensu::Plugin::Check::CLI
85
56
  proc: proc(&:to_i),
86
57
  default: 2
87
58
 
88
- option :ini,
89
- description: 'Configuration ini file',
90
- short: '-i',
91
- long: '--ini VALUE'
92
-
93
- def rabbit
94
- begin
95
- if config[:ini]
96
- ini = IniFile.load(config[:ini])
97
- section = ini['auth']
98
- username = section['username']
99
- password = section['password']
100
- else
101
- username = config[:username]
102
- password = config[:password]
103
- end
104
-
105
- connection = CarrotTop.new(
106
- host: config[:host],
107
- port: config[:port],
108
- user: username,
109
- password: password,
110
- ssl: config[:ssl]
111
- )
112
- rescue StandardError
113
- warning 'could not connect to rabbitmq'
114
- end
115
- connection
116
- end
117
-
118
59
  def return_condition(missing, critical, warning)
119
- if critical.count.positive? || missing.count.positive?
120
- message = ''
121
- message << "Queues in critical state: #{critical.join(', ')}. " if critical.count.positive?
122
- message << "Queues missing: #{missing.join(', ')}" if missing.count.positive?
123
- critical(message)
124
- elsif warning.count.positive?
60
+ if critical.count > 0 || missing.count > 0
61
+ message = []
62
+ message << "Queues in critical state: #{critical.join(', ')}. " if critical.count > 0
63
+ message << "Queues missing: #{missing.join(', ')}" if missing.count > 0
64
+ critical(message.join("\n"))
65
+ elsif warning.count > 0
125
66
  warning("Queues in warning state: #{warning.join(', ')}")
126
67
  else
127
68
  ok
@@ -129,30 +70,36 @@ class CheckRabbitMQConsumers < Sensu::Plugin::Check::CLI
129
70
  end
130
71
 
131
72
  def run
73
+ queue_list = queue_list_builder(config[:queue])
74
+ exclude_list = queue_list_builder(config[:exclude])
132
75
  # create arrays to hold failures
133
76
  missing = if config[:regex]
134
77
  []
135
78
  else
136
- config[:queue] || []
79
+ queue_list || []
137
80
  end
138
81
  critical = []
139
82
  warn = []
140
-
83
+ rabbitmq = acquire_rabbitmq_info
141
84
  begin
142
- rabbit.queues.each do |queue|
85
+ rabbitmq.queues.each do |queue|
143
86
  # if specific queues were passed only monitor those.
144
87
  # if specific queues to exclude were passed then skip those
145
88
  if config[:regex]
146
- next unless queue['name'] =~ /#{config[:queue].first}/
89
+ if config[:queue] && config[:exclude]
90
+ next unless queue['name'] =~ /#{queue_list.first}/ && queue['name'] !~ /#{exclude_list.first}/
91
+ else
92
+ next unless queue['name'] =~ /#{queue_list.first}/
93
+ end
147
94
  elsif config[:queue]
148
- next unless config[:queue].include?(queue['name'])
95
+ next unless queue_list.include?(queue['name'])
149
96
  elsif config[:exclude]
150
- next if config[:exclude].include?(queue['name'])
97
+ next if exclude_list.include?(queue['name'])
151
98
  end
152
99
  missing.delete(queue['name'])
153
100
  consumers = queue['consumers'] || 0
154
- critical.push(queue['name']) if consumers <= config[:critical]
155
- warn.push(queue['name']) if consumers <= config[:warn]
101
+ critical.push("#{queue['name']}:#{queue['consumers']}-Consumers") if consumers <= config[:critical]
102
+ warn.push("#{queue['name']}:#{queue['consumers']}-Consumers") if consumers <= config[:warn]
156
103
  end
157
104
  rescue StandardError
158
105
  critical 'Could not find any queue, check rabbitmq server'
@@ -83,6 +83,12 @@ module Sensu
83
83
  result_info
84
84
  end
85
85
 
86
+ def queue_list_builder(input)
87
+ return [] if input.nil?
88
+ return [input] if config[:regex]
89
+ input.split(',')
90
+ end
91
+
86
92
  def self.included(receiver)
87
93
  receiver.extend(Sensu::Plugin::RabbitMQ::Options)
88
94
  receiver.add_common_options
@@ -3,7 +3,7 @@
3
3
  module SensuPluginsRabbitMQ
4
4
  module Version
5
5
  MAJOR = 5
6
- MINOR = 1
6
+ MINOR = 2
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.1.0
4
+ version: 5.2.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-16 00:00:00.000000000 Z
11
+ date: 2018-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin