bin/metrics-es-node.rb in sensu-plugins-elasticsearch-0.3.1 vs bin/metrics-es-node.rb in sensu-plugins-elasticsearch-0.3.2

- old
+ new

@@ -84,11 +84,13 @@ rescue RestClient::RequestTimeout warning 'Connection timed out' end def run - if Gem::Version.new(acquire_es_version) >= Gem::Version.new('1.0.0') + es_version = Gem::Version.new(acquire_es_version) + + if es_version >= Gem::Version.new('1.0.0') ln = get_es_resource('/_nodes/_local') stats = get_es_resource('/_nodes/_local/stats') else ln = get_es_resource('/_cluster/nodes/_local') stats = get_es_resource('/_cluster/nodes/_local/stats') @@ -96,10 +98,14 @@ timestamp = Time.now.to_i node = stats['nodes'].values.first node['jvm']['mem']['heap_max_in_bytes'] = ln['nodes'].values.first['jvm']['mem']['heap_max_in_bytes'] metrics = {} - metrics['os.load_average'] = node['os']['load_average'][0] + if es_version >= Gem::Version.new('2.0.0') + metrics['os.load_average'] = node['os']['load_average'] + else + metrics['os.load_average'] = node['os']['load_average'][0] + end metrics['os.mem.free_in_bytes'] = node['os']['mem']['free_in_bytes'] metrics['process.mem.resident_in_bytes'] = node['process']['mem']['resident_in_bytes'] metrics['jvm.mem.heap_used_in_bytes'] = node['jvm']['mem']['heap_used_in_bytes'] metrics['jvm.mem.non_heap_used_in_bytes'] = node['jvm']['mem']['non_heap_used_in_bytes'] metrics['jvm.gc.collection_time_in_millis'] = node['jvm']['gc']['collection_time_in_millis']