bin/check-es-heap.rb in sensu-plugins-elasticsearch-0.4.2 vs bin/check-es-heap.rb in sensu-plugins-elasticsearch-0.4.3
- old
+ new
@@ -105,16 +105,15 @@
rescue JSON::ParserError
warning 'Elasticsearch API returned invalid JSON'
end
def acquire_heap_data(return_max = false)
- if Gem::Version.new(acquire_es_version) >= Gem::Version.new('1.0.0')
- stats = acquire_es_resource('/_nodes/_local/stats?jvm=true')
- node = stats['nodes'].keys.first
- else
- stats = acquire_es_resource('/_cluster/nodes/_local/stats?jvm=true')
- node = stats['nodes'].keys.first
- end
+ stats = if Gem::Version.new(acquire_es_version) >= Gem::Version.new('1.0.0')
+ acquire_es_resource('/_nodes/_local/stats?jvm=true')
+ else
+ acquire_es_resource('/_cluster/nodes/_local/stats?jvm=true')
+ end
+ node = stats['nodes'].keys.first
begin
if return_max
return stats['nodes'][node]['jvm']['mem']['heap_used_in_bytes'], stats['nodes'][node]['jvm']['mem']['heap_max_in_bytes']
else
stats['nodes'][node]['jvm']['mem']['heap_used_in_bytes']