sensu-plugins-rabbitmq 3.4.0 → 3.5.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
  SHA1:
3
- metadata.gz: 0dd465aac9095a55b092e291e9db39204a4788c5
4
- data.tar.gz: cd8aca106692da139aa6558ab507998c750281b8
3
+ metadata.gz: 1c69134806cf9022b7ae98acf067df1af22ff36d
4
+ data.tar.gz: 99201bec94d8734fb4eeaf26e708d7d99c465036
5
5
  SHA512:
6
- metadata.gz: 35d2c570af65f9457741f7f054c72f6ae1078482fa4df62d0bf77a8152224f1fd68067a8440344cb25f9001bf767fd4531c8ddf826de8aedce43a8f2c3290cff
7
- data.tar.gz: 24b37a3e73e585a6873e35abe56d52aba4b194f1e53dd528163424fd18c5e8e8b84cf83879d7060ee3398e9f91fe758d6039f900ff627a28a951dd2ade690719
6
+ metadata.gz: 0ac52d4769ba910b1f3c491fc41af7645b8257ecedb438c647a4b2889c011764cbe283ced41f0b86645e633191d5dad6ce35c1e5279de8731d8abed4fd6a8bb6
7
+ data.tar.gz: c5c23a7709b88182e8e4100685cc607cf45e1575e03db7fe1c22347fb05d071db81eb64720a463355644246c08f3eccaa3f145707243b7a9523c7ffe67f72712
data/CHANGELOG.md CHANGED
@@ -5,7 +5,12 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
- ## [2017-08-20] - 2017-08-20
8
+ ## [3.5.0] - 2017-09-05
9
+ ### Changed
10
+ - RabbitMQ module with common code (@rthouvenin)
11
+ - Check and Metrics base classes (@rthouvenin)
12
+
13
+ ## [3.4.0] - 2017-08-20
9
14
  ### Added
10
15
  - check-rabbitmq-amqp-alive.rb: Added threading and heartbeat interval options (@bdeo)
11
16
 
@@ -14,10 +19,12 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
14
19
  - check-rabbitmq-consumers.rb: Added ability to select queues with regular expressions. (@jtduby)
15
20
 
16
21
  ### Added
17
- - ruby 2.4 support (@majormoses)
22
+ - ruby 2.4 support (@majormoses)
18
23
 
24
+ ### Changed
25
+ - metrics-rabbitmq-queue, metrics-rabbitmq-exchange, check-rabbitmq-queue: use the new base classes (@rthouvenin)
19
26
  ### Fixed
20
- - PR template spelling (@majormoses)
27
+ - PR template spelling (@majormoses)
21
28
 
22
29
  ## [3.2.0] - 2017-06-20
23
30
  ### Added
@@ -156,7 +163,8 @@ NOTE: this release changes the option flags in check-rabbitmq-node-health.rb to
156
163
  - Remove copy paste errors in the Readme
157
164
  - Removed Rubygems require Ruby 1.8.7 backwards compatibility from all plugins
158
165
 
159
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/3.3.0...HEAD
166
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/3.5.0...HEAD
167
+ [3.5.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/3.4.0...3.5.0
160
168
  [3.4.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/3.3.0...3.4.0
161
169
  [3.3.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/3.2.0...3.3.0
162
170
  [3.2.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/3.1.1...3.2.0
@@ -21,46 +21,10 @@
21
21
  # Released under the same terms as Sensu (the MIT license); see LICENSE
22
22
  # for details.
23
23
 
24
- require 'sensu-plugin/check/cli'
25
- require 'socket'
26
- require 'carrot-top'
27
- require 'inifile'
24
+ require 'sensu-plugins-rabbitmq'
28
25
 
29
26
  # main plugin class
30
- class CheckRabbitMQMessages < 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 :vhost,
43
- description: 'RabbitMQ vhost',
44
- short: '-v',
45
- long: '--vhost VHOST',
46
- default: ''
47
-
48
- option :ssl,
49
- description: 'Enable SSL for connection to the API',
50
- long: '--ssl',
51
- boolean: true,
52
- default: false
53
-
54
- option :username,
55
- description: 'RabbitMQ management API user',
56
- long: '--username USER',
57
- default: 'guest'
58
-
59
- option :password,
60
- description: 'RabbitMQ management API password',
61
- long: '--password PASSWORD',
62
- default: 'guest'
63
-
27
+ class CheckRabbitMQMessages < Sensu::Plugin::RabbitMQ::Check
64
28
  option :queue,
65
29
  description: 'RabbitMQ queue to monitor',
66
30
  long: '--queue queue_names',
@@ -103,36 +67,6 @@ class CheckRabbitMQMessages < Sensu::Plugin::Check::CLI
103
67
  boolean: true,
104
68
  default: false
105
69
 
106
- option :ini,
107
- description: 'Configuration ini file',
108
- short: '-i',
109
- long: '--ini VALUE'
110
-
111
- def acquire_rabbitmq_info
112
- begin
113
- if config[:ini]
114
- ini = IniFile.load(config[:ini])
115
- section = ini['auth']
116
- username = section['username']
117
- password = section['password']
118
- else
119
- username = config[:username]
120
- password = config[:password]
121
- end
122
-
123
- rabbitmq_info = CarrotTop.new(
124
- host: config[:host],
125
- port: config[:port],
126
- user: username,
127
- password: password,
128
- ssl: config[:ssl]
129
- )
130
- rescue
131
- warning 'could not get rabbitmq info'
132
- end
133
- rabbitmq_info
134
- end
135
-
136
70
  def run
137
71
  @crit = []
138
72
  @warn = []
@@ -24,44 +24,10 @@
24
24
  # Released under the same terms as Sensu (the MIT license); see LICENSE
25
25
  # for details.
26
26
 
27
- require 'sensu-plugin/metric/cli'
28
- require 'socket'
29
- require 'carrot-top'
30
- require 'inifile'
27
+ require 'sensu-plugins-rabbitmq'
31
28
 
32
29
  # main plugin class
33
- class RabbitMQExchangeMetrics < Sensu::Plugin::Metric::CLI::Graphite
34
- option :host,
35
- description: 'RabbitMQ management API host',
36
- long: '--host HOST',
37
- default: 'localhost'
38
-
39
- option :port,
40
- description: 'RabbitMQ management API port',
41
- long: '--port PORT',
42
- proc: proc(&:to_i),
43
- default: 15_672
44
-
45
- option :vhost,
46
- description: 'Regular expression for filtering the RabbitMQ vhost',
47
- short: '-v',
48
- long: '--vhost VHOST'
49
-
50
- option :username,
51
- description: 'RabbitMQ management API user',
52
- long: '--username USER',
53
- default: 'guest'
54
-
55
- option :password,
56
- description: 'RabbitMQ management API password',
57
- long: '--password PASSWORD',
58
- default: 'guest'
59
-
60
- option :scheme,
61
- description: 'Metric naming scheme, text to prepend to $exchange_name.$metric',
62
- long: '--scheme SCHEME',
63
- default: "#{Socket.gethostname}.rabbitmq"
64
-
30
+ class RabbitMQExchangeMetrics < Sensu::Plugin::RabbitMQ::Metrics
65
31
  option :filter,
66
32
  description: 'Regular expression for filtering exchanges',
67
33
  long: '--filter REGEX'
@@ -70,61 +36,9 @@ class RabbitMQExchangeMetrics < Sensu::Plugin::Metric::CLI::Graphite
70
36
  description: 'Regular expression for filtering metrics in each exchange',
71
37
  long: '--metrics REGEX'
72
38
 
73
- option :ssl,
74
- description: 'Enable SSL for connection to the API',
75
- long: '--ssl',
76
- boolean: true,
77
- default: false
78
-
79
- option :ini,
80
- description: 'Configuration ini file',
81
- short: '-i',
82
- long: '--ini VALUE'
83
-
84
- def acquire_rabbitmq_exchanges
85
- begin
86
- if config[:ini]
87
- ini = IniFile.load(config[:ini])
88
- section = ini['auth']
89
- username = section['username']
90
- password = section['password']
91
- else
92
- username = config[:username]
93
- password = config[:password]
94
- end
95
-
96
- rabbitmq_info = CarrotTop.new(
97
- host: config[:host],
98
- port: config[:port],
99
- user: username,
100
- password: password,
101
- ssl: config[:ssl]
102
- )
103
- rescue
104
- warning 'could not get rabbitmq exchange info'
105
- end
106
-
107
- if config[:vhost]
108
- return rabbitmq_info.exchanges.select { |x| x['vhost'].match(config[:vhost]) }
109
- end
110
-
111
- rabbitmq_info.exchanges
112
- end
113
-
114
- def dotted_keys(hash, prefix = '', keys = [])
115
- hash.each do |k, v|
116
- if v.is_a? Hash
117
- keys = dotted_keys(v, prefix + k + '.', keys)
118
- else
119
- keys << prefix + k
120
- end
121
- end
122
- keys
123
- end
124
-
125
39
  def run
126
40
  timestamp = Time.now.to_i
127
- acquire_rabbitmq_exchanges.each do |exchange|
41
+ acquire_rabbitmq_info(:exchanges).each do |exchange|
128
42
  if config[:filter]
129
43
  next unless exchange['name'].match(config[:filter])
130
44
  end
@@ -28,44 +28,10 @@
28
28
  # Released under the same terms as Sensu (the MIT license); see LICENSE
29
29
  # for details.
30
30
 
31
- require 'sensu-plugin/metric/cli'
32
- require 'socket'
33
- require 'carrot-top'
34
- require 'inifile'
31
+ require 'sensu-plugins-rabbitmq'
35
32
 
36
33
  # main plugin class
37
- class RabbitMQMetrics < Sensu::Plugin::Metric::CLI::Graphite
38
- option :host,
39
- description: 'RabbitMQ management API host',
40
- long: '--host HOST',
41
- default: 'localhost'
42
-
43
- option :port,
44
- description: 'RabbitMQ management API port',
45
- long: '--port PORT',
46
- proc: proc(&:to_i),
47
- default: 15_672
48
-
49
- option :vhost,
50
- description: 'Regular expression for filtering the RabbitMQ vhost',
51
- short: '-v',
52
- long: '--vhost VHOST'
53
-
54
- option :username,
55
- description: 'RabbitMQ management API user',
56
- long: '--username USER',
57
- default: 'guest'
58
-
59
- option :password,
60
- description: 'RabbitMQ management API password',
61
- long: '--password PASSWORD',
62
- default: 'guest'
63
-
64
- option :scheme,
65
- description: 'Metric naming scheme, text to prepend to $queue_name.$metric',
66
- long: '--scheme SCHEME',
67
- default: "#{Socket.gethostname}.rabbitmq"
68
-
34
+ class RabbitMQQueueMetrics < Sensu::Plugin::RabbitMQ::Metrics
69
35
  option :filter,
70
36
  description: 'Regular expression for filtering queues',
71
37
  long: '--filter REGEX'
@@ -75,61 +41,9 @@ class RabbitMQMetrics < Sensu::Plugin::Metric::CLI::Graphite
75
41
  long: '--metrics REGEX',
76
42
  default: '^messages$|consumers|drain_time|avg_egress'
77
43
 
78
- option :ssl,
79
- description: 'Enable SSL for connection to the API',
80
- long: '--ssl',
81
- boolean: true,
82
- default: false
83
-
84
- option :ini,
85
- description: 'Configuration ini file',
86
- short: '-i',
87
- long: '--ini VALUE'
88
-
89
- def acquire_rabbitmq_queues
90
- begin
91
- if config[:ini]
92
- ini = IniFile.load(config[:ini])
93
- section = ini['auth']
94
- username = section['username']
95
- password = section['password']
96
- else
97
- username = config[:username]
98
- password = config[:password]
99
- end
100
-
101
- rabbitmq_info = CarrotTop.new(
102
- host: config[:host],
103
- port: config[:port],
104
- user: username,
105
- password: password,
106
- ssl: config[:ssl]
107
- )
108
- rescue
109
- warning 'could not get rabbitmq queue info'
110
- end
111
-
112
- if config[:vhost]
113
- return rabbitmq_info.queues.select { |x| x['vhost'].match(config[:vhost]) }
114
- end
115
-
116
- rabbitmq_info.queues
117
- end
118
-
119
- def dotted_keys(hash, prefix = '', keys = [])
120
- hash.each do |k, v|
121
- if v.is_a? Hash
122
- keys = dotted_keys(v, prefix + k + '.', keys)
123
- else
124
- keys << prefix + k
125
- end
126
- end
127
- keys
128
- end
129
-
130
44
  def run
131
45
  timestamp = Time.now.to_i
132
- acquire_rabbitmq_queues.each do |queue|
46
+ acquire_rabbitmq_info(:queues).each do |queue|
133
47
  if config[:filter]
134
48
  next unless queue['name'].match(config[:filter])
135
49
  end
@@ -1 +1,5 @@
1
+ require 'ruby_dig'
2
+
1
3
  require 'sensu-plugins-rabbitmq/version'
4
+ require 'sensu-plugins-rabbitmq/check'
5
+ require 'sensu-plugins-rabbitmq/metrics'
@@ -0,0 +1,17 @@
1
+ require 'sensu-plugin/check/cli'
2
+ require 'sensu-plugins-rabbitmq/rabbitmq'
3
+
4
+ module Sensu
5
+ module Plugin
6
+ module RabbitMQ
7
+ class Check < Sensu::Plugin::Check::CLI
8
+ include Sensu::Plugin::RabbitMQ::Common
9
+
10
+ # To avoid complaints from mother class at the end of tests (at_exit handler)
11
+ def run
12
+ ok
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,34 @@
1
+ require 'sensu-plugin/metric/cli'
2
+ require 'socket'
3
+ require 'sensu-plugins-rabbitmq/rabbitmq'
4
+
5
+ module Sensu
6
+ module Plugin
7
+ module RabbitMQ
8
+ class Metrics < Sensu::Plugin::Metric::CLI::Graphite
9
+ include Sensu::Plugin::RabbitMQ::Common
10
+
11
+ option :scheme,
12
+ description: 'Metric naming scheme',
13
+ long: '--scheme SCHEME',
14
+ default: "#{Socket.gethostname}.rabbitmq"
15
+
16
+ def dotted_keys(hash, prefix = '', keys = [])
17
+ hash.each do |k, v|
18
+ if v.is_a? Hash
19
+ keys = dotted_keys(v, prefix + k + '.', keys)
20
+ else
21
+ keys << prefix + k
22
+ end
23
+ end
24
+ keys
25
+ end
26
+
27
+ # To avoid complaints from mother class at the end of tests (at_exit handler)
28
+ def run
29
+ ok
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,91 @@
1
+ require 'carrot-top'
2
+ require 'inifile'
3
+
4
+ module Sensu
5
+ module Plugin
6
+ module RabbitMQ
7
+ module Options
8
+ def add_common_options
9
+ option :host,
10
+ description: 'RabbitMQ management API host',
11
+ long: '--host HOST',
12
+ default: 'localhost'
13
+
14
+ option :port,
15
+ description: 'RabbitMQ management API port',
16
+ long: '--port PORT',
17
+ proc: proc(&:to_i),
18
+ default: 15_672
19
+
20
+ option :vhost,
21
+ description: 'Regular expression for filtering the RabbitMQ vhost',
22
+ short: '-v',
23
+ long: '--vhost VHOST',
24
+ default: ''
25
+
26
+ option :username,
27
+ description: 'RabbitMQ management API user',
28
+ long: '--username USER',
29
+ default: 'guest'
30
+
31
+ option :password,
32
+ description: 'RabbitMQ management API password',
33
+ long: '--password PASSWORD',
34
+ default: 'guest'
35
+
36
+ option :ssl,
37
+ description: 'Enable SSL for connection to the API',
38
+ long: '--ssl',
39
+ boolean: true,
40
+ default: false
41
+
42
+ option :ini,
43
+ description: 'Configuration ini file',
44
+ short: '-i',
45
+ long: '--ini VALUE'
46
+ end
47
+ end
48
+
49
+ module Common
50
+ def acquire_rabbitmq_info(property = nil)
51
+ begin
52
+ if config[:ini]
53
+ ini = IniFile.load(config[:ini])
54
+ section = ini['auth']
55
+ username = section['username']
56
+ password = section['password']
57
+ else
58
+ username = config[:username]
59
+ password = config[:password]
60
+ end
61
+
62
+ rabbitmq_info = CarrotTop.new(
63
+ host: config[:host],
64
+ port: config[:port],
65
+ user: username,
66
+ password: password,
67
+ ssl: config[:ssl]
68
+ )
69
+ rescue
70
+ warning 'could not get rabbitmq info'
71
+ end
72
+
73
+ result_info = rabbitmq_info
74
+ unless property.nil?
75
+ result_info = rabbitmq_info.send property
76
+ if config[:vhost] != ''
77
+ result_info.select! { |x| x['vhost'].match(config[:vhost]) }
78
+ end
79
+ end
80
+
81
+ result_info
82
+ end
83
+
84
+ def self.included(receiver)
85
+ receiver.extend(Sensu::Plugin::RabbitMQ::Options)
86
+ receiver.add_common_options
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -3,7 +3,7 @@
3
3
  module SensuPluginsRabbitMQ
4
4
  module Version
5
5
  MAJOR = 3
6
- MINOR = 4
6
+ MINOR = 5
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: 3.4.0
4
+ version: 3.5.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: 2017-08-20 00:00:00.000000000 Z
11
+ date: 2017-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
110
  version: 3.0.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: ruby_dig
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 0.0.2
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 0.0.2
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: bundler
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -276,6 +290,9 @@ files:
276
290
  - bin/metrics-rabbitmq-overview.rb
277
291
  - bin/metrics-rabbitmq-queue.rb
278
292
  - lib/sensu-plugins-rabbitmq.rb
293
+ - lib/sensu-plugins-rabbitmq/check.rb
294
+ - lib/sensu-plugins-rabbitmq/metrics.rb
295
+ - lib/sensu-plugins-rabbitmq/rabbitmq.rb
279
296
  - lib/sensu-plugins-rabbitmq/version.rb
280
297
  homepage: https://github.com/sensu-plugins/sensu-plugins-rabbitmq
281
298
  licenses:
@@ -303,7 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
303
320
  version: '0'
304
321
  requirements: []
305
322
  rubyforge_project:
306
- rubygems_version: 2.4.5
323
+ rubygems_version: 2.6.13
307
324
  signing_key:
308
325
  specification_version: 4
309
326
  summary: Sensu plugins for rabbitmq