Skip to content
Browse files

Fixed issue with the reported GC collection times

The elasticsearch cluster nodes stats API returns the total time spent in GC...ever...and the number of GC operations done.  Therefore, the time the node is spending doing GC is total time / number of operations.
  • Loading branch information...
1 parent 8f982b4 commit e5707ed1d22a8715c5d5b8cf586293ba0e02897b @jwood jwood committed Aug 29, 2011
Showing with 10 additions and 3 deletions.
  1. +10 −3 elasticsearch/elasticsearch_cluster_node_status_plugin.rb
View
13 elasticsearch/elasticsearch_cluster_node_status_plugin.rb
@@ -40,9 +40,10 @@ def build_report
report(:non_heap_used => b_to_mb(response['jvm']['mem']['non_heap_used_in_bytes'] || 0))
report(:non_heap_committed => b_to_mb(response['jvm']['mem']['non_heap_committed_in_bytes'] || 0))
report(:threads_count => response['jvm']['threads']['count'] || 0)
- report(:gc_collection_time => response['jvm']['gc']['collection_time_in_millis'] || 0)
- report(:gc_parnew_collection_time => response['jvm']['gc']['collectors']['ParNew']['collection_time_in_millis'] || 0)
- report(:gc_cms_collection_time => response['jvm']['gc']['collectors']['ConcurrentMarkSweep']['collection_time_in_millis'] || 0)
+
+ report(:gc_collection_time => gc_time(response['jvm']['gc']))
+ report(:gc_parnew_collection_time => gc_time(response['jvm']['gc']['collectors']['ParNew']))
+ report(:gc_cms_collection_time => gc_time(response['jvm']['gc']['collectors']['ConcurrentMarkSweep']))
rescue OpenURI::HTTPError
error("Stats URL not found", "Please ensure the base url for elasticsearch cluster node stats is correct. Current URL: \n\n#{base_url}")
@@ -54,5 +55,11 @@ def b_to_mb(bytes)
bytes && bytes.to_f / 1024 / 1024
end
+ def gc_time(data)
+ collection_time = data['collection_time_in_millis'] || 0
+ gc_operations = data['collection_count'] || 1
+ collection_time / gc_operations
+ end
+
end

0 comments on commit e5707ed

Please sign in to comment.
Something went wrong with that request. Please try again.