sensu-plugins-rabbitmq 3.0.0 → 3.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
  SHA1:
3
- metadata.gz: 4136a3c48a94763e3ab822775e4d21a832b10887
4
- data.tar.gz: eab91431b9a3e361e955f23ed3c383d7832344fb
3
+ metadata.gz: 8c4af6295e3502323bc33b8a0c7e8468fa0bc049
4
+ data.tar.gz: 7cf40311405259b11315d2266fc1d28b35faa0ef
5
5
  SHA512:
6
- metadata.gz: e8b04c93a18c80b25bf0ea1f1025d7f1d0ca24facd5802a71f758afa1d1dbfe00b8a8a471fbcb6115c1e4a261c052c77566dd3f09343064abf3c682ee3b32756
7
- data.tar.gz: da132f2cc3c15f1f22dc1280d9192f6f800aa50f612c503de942d60321e0d7375996092b2d00ac2429c62fd0a514323586b7a7908b1db1a7bcdc188bae693359
6
+ metadata.gz: 6b8628a015ddb462ef3c0ad1e2136c7e260dc9a0c9ee4a8c02d9fcff94a5546ad6a70c1a87a0d98d2d574812f3d37b8debcbcf6fc6b703ce8c5446fe1e0ac0c1
7
+ data.tar.gz: 8267f2febc301f37f6d0adb030484da3f70f59c5d85e9ecf1ef07a244c5aaed9ccc7076f7ffafd871af0d09651c1e3688325b034226fa68083ab16cb31786209
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
+ ## [3.1.0] - 2017-05-16
8
+ ### Added
9
+ - metrics-rabbitmq-queue.rb: --metrics option to specifiy which metrics to gather (@rthouvenin)
10
+
7
11
  ## [3.0.0] - 2017-05-10
8
12
  ### Breaking change
9
13
  - Previously some checks used --user to specify username, now all scripts use --username
@@ -129,7 +133,8 @@ NOTE: this release changes the option flags in check-rabbitmq-node-health.rb to
129
133
  - Remove copy paste errors in the Readme
130
134
  - Removed Rubygems require Ruby 1.8.7 backwards compatibility from all plugins
131
135
 
132
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/3.0.0...HEAD
136
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/3.1.0...HEAD
137
+ [3.1.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/3.0.0...3.1.0
133
138
  [3.0.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/2.3.0...3.0.0
134
139
  [2.3.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/2.2.0...2.3.0
135
140
  [2.2.0]: https://github.com/sensu-plugins/sensu-plugins-rabbitmq/compare/2.1.0...2.2.0
@@ -5,11 +5,12 @@
5
5
  # ===
6
6
  #
7
7
  # DESCRIPTION:
8
- # This plugin checks gathers the following per queue rabbitmq metrics:
8
+ # This plugin checks gathers by default the following per queue rabbitmq metrics:
9
9
  # - message count
10
10
  # - average egress rate
11
11
  # - "drain time" metric, which is the time a queue will take to reach 0 based on the egress rate
12
12
  # - consumer count
13
+ # The list of gathered metrics can also be specified with an option
13
14
  #
14
15
  # PLATFORMS:
15
16
  # Linux, BSD, Solaris
@@ -22,6 +23,7 @@
22
23
  # LICENSE:
23
24
  # Copyright 2011 Sonian, Inc <chefs@sonian.net>
24
25
  # Copyright 2015 Tim Smith <tim@cozy.co> and Cozy Services Ltd.
26
+ # Copyright 2017 Romain Thouvenin <romain@thouvenin.pro>
25
27
  #
26
28
  # Released under the same terms as Sensu (the MIT license); see LICENSE
27
29
  # for details.
@@ -68,6 +70,11 @@ class RabbitMQMetrics < Sensu::Plugin::Metric::CLI::Graphite
68
70
  description: 'Regular expression for filtering queues',
69
71
  long: '--filter REGEX'
70
72
 
73
+ option :metrics,
74
+ description: 'Regular expression for filtering metrics in each queue',
75
+ long: '--metrics REGEX',
76
+ default: '^messages$|consumers|drain_time|avg_egress'
77
+
71
78
  option :ssl,
72
79
  description: 'Enable SSL for connection to the API',
73
80
  long: '--ssl',
@@ -109,6 +116,17 @@ class RabbitMQMetrics < Sensu::Plugin::Metric::CLI::Graphite
109
116
  rabbitmq_info.queues
110
117
  end
111
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
+
112
130
  def run
113
131
  timestamp = Time.now.to_i
114
132
  acquire_rabbitmq_queues.each do |queue|
@@ -120,16 +138,21 @@ class RabbitMQMetrics < Sensu::Plugin::Metric::CLI::Graphite
120
138
  queue['messages'] ||= 0
121
139
  drain_time = queue['messages'] / queue['backing_queue_status']['avg_egress_rate']
122
140
  drain_time = 0 if drain_time.nan? || drain_time.infinite? # 0 rate with 0 messages is 0 time to drain
123
- output([config[:scheme], queue['name'], 'drain_time'].join('.'), drain_time.to_i, timestamp)
124
-
125
- %w(messages consumers).each do |metric|
126
- output([config[:scheme], queue['name'], metric].join('.'), queue[metric], timestamp)
141
+ queue['drain_time'] = drain_time.to_i
142
+
143
+ metrics = dotted_keys(queue)
144
+ metrics.each do |metric|
145
+ next unless metric.match(config[:metrics])
146
+ value = queue.dig(*metric.split('.'))
147
+ # Special case of ingress and egress rates for backward-compatibility
148
+ if metric =~ 'backing_queue_status.avg'
149
+ value = format('%.4f', value)
150
+ metric = metric.split('.')[-1]
151
+ end
152
+ output("#{config[:scheme]}.#{queue['name']}.#{metric}", value, timestamp) unless value.nil?
127
153
  end
128
-
129
- # fetch the average egress rate of the queue
130
- rate = format('%.4f', queue['backing_queue_status']['avg_egress_rate'])
131
- output([config[:scheme], queue['name'], 'avg_egress_rate'].join('.'), rate, timestamp)
132
154
  end
155
+
133
156
  ok
134
157
  end
135
158
  end
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsRabbitMQ
2
2
  module Version
3
3
  MAJOR = 3
4
- MINOR = 0
4
+ MINOR = 1
5
5
  PATCH = 0
6
6
 
7
7
  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.0.0
4
+ version: 3.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: 2017-05-10 00:00:00.000000000 Z
11
+ date: 2017-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin