sensu-plugins-rabbitmq 3.1.1 → 3.2.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: ed699b605f7a834ca8cf0052ca50eda76337f881
4
- data.tar.gz: 04a21974523874b69f4555ef5b1f592cd88e1d7f
3
+ metadata.gz: b3566139d4b9ef5dce00928ee03a851735572fb0
4
+ data.tar.gz: 1e2b59c503c0e8fad702558068746944682500b5
5
5
  SHA512:
6
- metadata.gz: 07e1ef662505c7ef3cb94d4d33beaf0ebbeec0c4730848db0bb3530eb2565e72aa2527b852fa0d634ef7ad8df11ad57a7f14b8d120f71225179613e84863f7a1
7
- data.tar.gz: f79cd6141ccdc619274a2c8066fc76d7a55df64e0968f409429a2683c385c8a0841de10bb3162972b14a52e1c403a080e66420e5ca1da2970f6f53981c2efedd
6
+ metadata.gz: 21f1f3fc7372c3e79b7241d6cb7fb7867b39822c75e57a11c807d559c00fb7a10e7e62a6f560fe7cbdd9c8c7c8799d386bb96ae0761ddad09d66b2c72cf43a59
7
+ data.tar.gz: 66ee9067f134abc57fa81206f52adc7173b7f1190a792b90dc9155631601d522edf0a8fd899c921e5c07cc8500b0ff51d20358a804c7861e08ae7ea7d618a78c
data/CHANGELOG.md CHANGED
@@ -1,9 +1,14 @@
1
- #Change Log
1
+ # Change Log
2
2
  This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
4
  This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
5
 
6
6
  ## [Unreleased]
7
+
8
+ ## [3.2.0] - 2017-06-20
9
+ ### Added
10
+ - metrics-rabbitmq-exchange: new metrics for exchange, working similarly to queue metrics (@rthouvenin)
11
+
7
12
  ## [3.1.1] - 2017-05-17
8
13
  ### Fixed
9
14
  - metrics-rabbitmq-queue.rb: Fix use of =~ operator
@@ -137,7 +142,8 @@ NOTE: this release changes the option flags in check-rabbitmq-node-health.rb to
137
142
  - Remove copy paste errors in the Readme
138
143
  - Removed Rubygems require Ruby 1.8.7 backwards compatibility from all plugins
139
144
 
140
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/3.1.1...HEAD
145
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/3.2.0...HEAD
146
+ [3.2.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/3.1.1...3.2.0
141
147
  [3.1.1]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/3.1.0...3.1.1
142
148
  [3.1.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/3.0.0...3.1.0
143
149
  [3.0.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/2.3.0...3.0.0
data/README.md CHANGED
@@ -22,6 +22,7 @@
22
22
  * bin/check-rabbitmq-stomp-alive.rb
23
23
  * bin/metrics-rabbitmq-overview.rb
24
24
  * bin/metrics-rabbitmq-queue.rb
25
+ * bin/metrics-rabbitmq-exchange.rb
25
26
 
26
27
  ## Usage
27
28
 
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+ #
4
+ # RabbitMQ Exchange Metrics
5
+ # ===
6
+ #
7
+ # DESCRIPTION:
8
+ # This plugin gathers by default all the available exchange metrics.
9
+ # The list of gathered metrics can also be specified with an option
10
+ #
11
+ # Code mostly copied from metrics-rabbitmq-queue
12
+ #
13
+ # PLATFORMS:
14
+ # Linux, BSD, Solaris
15
+ #
16
+ # DEPENDENCIES:
17
+ # RabbitMQ rabbitmq_management plugin
18
+ # gem: sensu-plugin
19
+ # gem: carrot-top
20
+ #
21
+ # LICENSE:
22
+ # Copyright 2017 Romain Thouvenin <romain@thouvenin.pro>
23
+ #
24
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
25
+ # for details.
26
+
27
+ require 'sensu-plugin/metric/cli'
28
+ require 'socket'
29
+ require 'carrot-top'
30
+ require 'inifile'
31
+
32
+ # 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
+
65
+ option :filter,
66
+ description: 'Regular expression for filtering exchanges',
67
+ long: '--filter REGEX'
68
+
69
+ option :metrics,
70
+ description: 'Regular expression for filtering metrics in each exchange',
71
+ long: '--metrics REGEX'
72
+
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
+ def run
126
+ timestamp = Time.now.to_i
127
+ acquire_rabbitmq_exchanges.each do |exchange|
128
+ if config[:filter]
129
+ next unless exchange['name'].match(config[:filter])
130
+ end
131
+
132
+ metrics = dotted_keys(exchange)
133
+ metrics.each do |metric|
134
+ if config[:metrics]
135
+ next unless metric.match(config[:metrics])
136
+ end
137
+ value = exchange.dig(*metric.split('.'))
138
+ output("#{config[:scheme]}.#{exchange['name']}.#{metric}", value, timestamp) unless value.nil?
139
+ end
140
+ end
141
+
142
+ ok
143
+ end
144
+ end
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsRabbitMQ
2
2
  module Version
3
3
  MAJOR = 3
4
- MINOR = 1
5
- PATCH = 1
4
+ MINOR = 2
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
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.1.1
4
+ version: 3.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: 2017-05-17 00:00:00.000000000 Z
11
+ date: 2017-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -252,6 +252,7 @@ executables:
252
252
  - check-rabbitmq-queue-drain-time.rb
253
253
  - check-rabbitmq-queue.rb
254
254
  - check-rabbitmq-stomp-alive.rb
255
+ - metrics-rabbitmq-exchange.rb
255
256
  - metrics-rabbitmq-overview.rb
256
257
  - metrics-rabbitmq-queue.rb
257
258
  extensions: []
@@ -271,6 +272,7 @@ files:
271
272
  - bin/check-rabbitmq-queue-drain-time.rb
272
273
  - bin/check-rabbitmq-queue.rb
273
274
  - bin/check-rabbitmq-stomp-alive.rb
275
+ - bin/metrics-rabbitmq-exchange.rb
274
276
  - bin/metrics-rabbitmq-overview.rb
275
277
  - bin/metrics-rabbitmq-queue.rb
276
278
  - lib/sensu-plugins-rabbitmq.rb