sensu-plugins-elasticsearch 1.7.1 → 1.8.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 +5 -5
- data/CHANGELOG.md +8 -2
- data/bin/check-es-heap.rb +59 -32
- data/lib/sensu-plugins-elasticsearch/version.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5014ee2207634368bdbc7c2c04c7bd172ead09d0e613ef241aec1c323508653d
|
4
|
+
data.tar.gz: b2614e8f3bd7c5098895b23a25e0b7ae10b9319292254d5ddc082f625801b29f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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
|
124
|
-
|
125
|
-
|
126
|
-
|
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
|
134
|
+
acquire_es_resource('/_nodes/_local/stats')
|
135
135
|
end
|
136
|
-
|
137
|
-
|
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
|
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
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
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
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
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
|
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.
|
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-
|
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.
|
297
|
+
rubygems_version: 2.7.2
|
298
298
|
signing_key:
|
299
299
|
specification_version: 4
|
300
300
|
summary: Sensu plugins for elasticsearch
|