bin/check-es-heap.rb in sensu-plugins-elasticsearch-1.12.0 vs bin/check-es-heap.rb in sensu-plugins-elasticsearch-2.0.0
- old
+ new
@@ -140,11 +140,11 @@
end
end
def acquire_heap_data(node)
return node['jvm']['mem']['heap_used_in_bytes'], node['jvm']['mem']['heap_max_in_bytes']
- rescue
+ rescue StandardError
warning 'Failed to obtain heap used in bytes'
end
def acquire_heap_usage(heap_used, heap_max, node_name)
if config[:percentage]
@@ -164,10 +164,10 @@
def run
stats = acquire_stats
status = { crit: '', warn: '', ok: '' }
# Check all the nodes in the cluster, alert if any of the nodes have heap usage above thresholds
- stats['nodes'].each do |_, node|
+ stats['nodes'].each_value do |node|
heap_used, heap_max = acquire_heap_data(node)
heap_usage, output = acquire_heap_usage(heap_used, heap_max, node['name'])
if heap_usage >= config[:crit]
status[:crit] += output
elsif heap_usage >= config[:warn]