sensu-plugins-elasticsearch 1.7.1 → 1.8.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
- SHA1:
3
- metadata.gz: 9b5d19c687717bb77c715fe191176912e2b4eeb0
4
- data.tar.gz: ba45b265535b3a4829e2ffbde77994a9f0c8367a
2
+ SHA256:
3
+ metadata.gz: 5014ee2207634368bdbc7c2c04c7bd172ead09d0e613ef241aec1c323508653d
4
+ data.tar.gz: b2614e8f3bd7c5098895b23a25e0b7ae10b9319292254d5ddc082f625801b29f
5
5
  SHA512:
6
- metadata.gz: 9ccf40f6c0612d23fe4f46215497f68c61109243dca77ca4da7f47808242f7371b20083f5c239d94a662e3f6fd3eb1467e26d1cee8975abb9bb1570bd7aaa374
7
- data.tar.gz: 659d435cabed3488b826d6f1a4b8947e86bbe43655b3f6fd761f0414be487e75242cdd8fffb0c70be764cb22aea617d98c3b75eb116a7711945fac08e9981e82
6
+ metadata.gz: b20456f73eedcf8ba79932343128513cdecaf06ffff3353d86b63a6131d8700f04005e0574ec279ea7de1f28a4e7412829ea153b0ddc99e67dafcf6f367b8852
7
+ data.tar.gz: eed566f1a9b0034b84cb06c167b9044a42bd38641b11d6be0e301518bdb2ef727ee35284344afa9a9d2d9b5a4fb1d54dad2036ae9a3ec6a80c33da0bff047c79
data/CHANGELOG.md CHANGED
@@ -1,10 +1,15 @@
1
1
  # Change Log
2
2
  This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
- This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
4
+ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [1.8.0] - 2017-11-21
9
+ ### Added
10
+ - bin/check-es-heap.rb: added support to check heap usage of all nodes in a cluster (@cihangirbesiktas)
11
+ - update changelog location guidelines (@majormoses)
12
+
8
13
  ## [1.7.1] - 2017-09-18
9
14
  ### Fixed
10
15
  - bin/check-es-cluster-health.rb and bin/check-es-cluster-status.rb fixed --alert-status failing to alert and allow absent value to alert on any status (@rwky)
@@ -200,7 +205,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
200
205
  - initial release
201
206
 
202
207
 
203
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/1.7.1...HEAD
208
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/1.8.0...HEAD
209
+ [1.8.0]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/1.7.1...1.8.0
204
210
  [1.7.1]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/1.7.0...1.7.1
205
211
  [1.7.0]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/1.6.1...1.7.0
206
212
  [1.6.1]: https://github.com/sensu-plugins/sensu-plugins-elasticsearch/compare/1.6.0...1.6.1
data/bin/check-es-heap.rb CHANGED
@@ -90,6 +90,12 @@ class ESHeap < Sensu::Plugin::Check::CLI
90
90
  short: '-e',
91
91
  long: '--https'
92
92
 
93
+ option :all,
94
+ description: 'Check all nodes in the ES cluster',
95
+ short: '-a',
96
+ long: '--all',
97
+ default: false
98
+
93
99
  def acquire_es_version
94
100
  info = acquire_es_resource('/')
95
101
  info['version']['number']
@@ -120,46 +126,67 @@ class ESHeap < Sensu::Plugin::Check::CLI
120
126
  warning 'Elasticsearch API returned invalid JSON'
121
127
  end
122
128
 
123
- def acquire_heap_data(return_max = false)
124
- stats = if Gem::Version.new(acquire_es_version) >= Gem::Version.new('1.0.0')
125
- acquire_es_resource('/_nodes/_local/stats')
126
- else
127
- acquire_es_resource('/_cluster/nodes/_local/stats')
128
- end
129
- node = stats['nodes'].keys.first
130
- begin
131
- if return_max
132
- return stats['nodes'][node]['jvm']['mem']['heap_used_in_bytes'], stats['nodes'][node]['jvm']['mem']['heap_max_in_bytes']
129
+ def acquire_stats
130
+ if Gem::Version.new(acquire_es_version) >= Gem::Version.new('1.0.0')
131
+ if config[:all]
132
+ acquire_es_resource('/_nodes/stats')
133
133
  else
134
- stats['nodes'][node]['jvm']['mem']['heap_used_in_bytes']
134
+ acquire_es_resource('/_nodes/_local/stats')
135
135
  end
136
- rescue
137
- warning 'Failed to obtain heap used in bytes'
136
+ elsif config[:all]
137
+ acquire_es_resource('/_cluster/nodes/stats')
138
+ else
139
+ acquire_es_resource('/_cluster/nodes/_local/stats')
138
140
  end
139
141
  end
140
142
 
141
- def run
143
+ def acquire_heap_data(node)
144
+ return node['jvm']['mem']['heap_used_in_bytes'], node['jvm']['mem']['heap_max_in_bytes']
145
+ rescue
146
+ warning 'Failed to obtain heap used in bytes'
147
+ end
148
+
149
+ def acquire_heap_usage(heap_used, heap_max, node_name)
142
150
  if config[:percentage]
143
- heap_used, heap_max = acquire_heap_data(true)
144
- heap_used_ratio = ((100 * heap_used) / heap_max).to_i
145
- message "Heap used in bytes #{heap_used} (#{heap_used_ratio}% full)"
146
- if heap_used_ratio >= config[:crit]
147
- critical
148
- elsif heap_used_ratio >= config[:warn]
149
- warning
150
- else
151
- ok
152
- end
151
+ heap_usage = ((100 * heap_used) / heap_max).to_i
152
+ output = if config[:all]
153
+ "Node #{node_name}: Heap used in bytes #{heap_used} (#{heap_usage}% full)\n"
154
+ else
155
+ "Heap used in bytes #{heap_used} (#{heap_usage}% full)"
156
+ end
153
157
  else
154
- heap_used = acquire_heap_data(false)
155
- message "Heap used in bytes #{heap_used}"
156
- if heap_used >= config[:crit]
157
- critical
158
- elsif heap_used >= config[:warn]
159
- warning
160
- else
161
- ok
158
+ heap_usage = heap_used
159
+ output = config[:all] ? "Node #{node_name}: Heap used in bytes #{heap_used}\n" : "Heap used in bytes #{heap_used}"
160
+ end
161
+ [heap_usage, output]
162
+ end
163
+
164
+ def run
165
+ stats = acquire_stats
166
+ status = { crit: '', warn: '', ok: '' }
167
+
168
+ # Check all the nodes in the cluster, alert if any of the nodes have heap usage above thresholds
169
+ stats['nodes'].each do |_, node|
170
+ heap_used, heap_max = acquire_heap_data(node)
171
+ heap_usage, output = acquire_heap_usage(heap_used, heap_max, node['name'])
172
+ if heap_usage >= config[:crit]
173
+ status[:crit] += output
174
+ elsif heap_usage >= config[:warn]
175
+ status[:warn] += output
176
+ elsif !config[:all]
177
+ status[:ok] += output
162
178
  end
163
179
  end
180
+
181
+ if !status[:crit].empty?
182
+ message status[:crit]
183
+ critical
184
+ elsif !status[:warn].empty?
185
+ message status[:warn]
186
+ warning
187
+ else
188
+ message status[:ok]
189
+ ok
190
+ end
164
191
  end
165
192
  end
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsElasticsearch
2
2
  module Version
3
3
  MAJOR = 1
4
- MINOR = 7
5
- PATCH = 1
4
+ MINOR = 8
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-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.8.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-09-18 00:00:00.000000000 Z
11
+ date: 2017-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -294,7 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
294
294
  version: '0'
295
295
  requirements: []
296
296
  rubyforge_project:
297
- rubygems_version: 2.6.13
297
+ rubygems_version: 2.7.2
298
298
  signing_key:
299
299
  specification_version: 4
300
300
  summary: Sensu plugins for elasticsearch