hadoop-metrics 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,7 +24,7 @@ module HadoopMetrics
24
24
 
25
25
  def gc
26
26
  disable_snake_case {
27
- result = via_jmx('java.lang:type=GarbageCollector,name=*').map { |jmx_gc_info|
27
+ result = query_jmx('java.lang:type=GarbageCollector,name=*').map { |jmx_gc_info|
28
28
  return nil if jmx_gc_info['LastGcInfo'].nil?
29
29
 
30
30
  gc_info = {'type' => (/PS Scavenge/.match(jmx_gc_info['name']) ? 'minor' : 'major')}
@@ -37,8 +37,35 @@ module HadoopMetrics
37
37
  }
38
38
  end
39
39
 
40
- def via_jmx(query, json_fields = [])
41
- HadoopMetrics.get_response(URI("http://#{@endpoint}/jmx?qry=#{query}"))['beans'].map { |jmx_json|
40
+ MegaByte = 1024.0 * 1024
41
+
42
+ def memory
43
+ disable_snake_case {
44
+ result = {}
45
+
46
+ memory = query_jmx('java.lang:type=Memory').first
47
+ heap, non_heap = memory['HeapMemoryUsage'], memory['NonHeapMemoryUsage']
48
+ result['committed'] = (heap['committed'] + non_heap['committed']) / MegaByte
49
+ result['used'] = (heap['used'] + non_heap['used']) / MegaByte
50
+ result['max'] = (heap['max'] + non_heap['max']) / MegaByte
51
+
52
+ arguments = get_jmx('java.lang:type=Runtime::InputArguments').first['InputArguments']
53
+ result['mx_option'] = arguments.select { |arg| arg =~ /-Xmx(.*)m/ }.last["-Xmx".size..-2].to_i
54
+
55
+ result
56
+ }
57
+ end
58
+
59
+ def query_jmx(query, json_fields = [])
60
+ via_jmx('qry', query, json_fields)
61
+ end
62
+
63
+ def get_jmx(query, json_fields = [])
64
+ via_jmx('get', query, json_fields)
65
+ end
66
+
67
+ def via_jmx(type, query, json_fields = [])
68
+ HadoopMetrics.get_response(URI("http://#{@endpoint}/jmx?#{type}=#{query}"))['beans'].map { |jmx_json|
42
69
  json_fields.each { |f|
43
70
  jmx_json[f] = JSON.parse(jmx_json[f])
44
71
  }
@@ -7,7 +7,7 @@ module HadoopMetrics
7
7
  JSON_FILED_VALUES = %W(SummaryJson AliveNodesInfoJson BlacklistedNodesInfoJson QueueInfoJson)
8
8
 
9
9
  def info
10
- via_jmx('hadoop:service=JobTracker,name=JobTrackerInfo', JSON_FILED_VALUES).first
10
+ query_jmx('hadoop:service=JobTracker,name=JobTrackerInfo', JSON_FILED_VALUES).first
11
11
  end
12
12
 
13
13
  def mapred(opts = {})
@@ -7,11 +7,11 @@ module HadoopMetrics
7
7
  JSON_FILED_VALUES = %W(LiveNodes DeadNodes DecomNodes NameDirStatuses)
8
8
 
9
9
  def info
10
- via_jmx('Hadoop:service=NameNode,name=NameNodeInfo', JSON_FILED_VALUES).first
10
+ query_jmx('Hadoop:service=NameNode,name=NameNodeInfo', JSON_FILED_VALUES).first
11
11
  end
12
12
 
13
13
  def dfs
14
- via_jmx('Hadoop:service=NameNode,name=FSNamesystem').first
14
+ query_jmx('Hadoop:service=NameNode,name=FSNamesystem').first
15
15
  end
16
16
  end
17
17
  end
@@ -7,7 +7,7 @@ module HadoopMetrics
7
7
  JSON_FILED_VALUES = %W(TasksInfoJson)
8
8
 
9
9
  def info
10
- via_jmx('hadoop:service=TaskTracker,name=TaskTrackerInfo', JSON_FILED_VALUES).first
10
+ query_jmx('hadoop:service=TaskTracker,name=TaskTrackerInfo', JSON_FILED_VALUES).first
11
11
  end
12
12
 
13
13
  def shuffle_output(opts = {})
@@ -1,3 +1,3 @@
1
1
  module HadoopMetrics
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hadoop-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -59,7 +59,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
59
59
  version: '0'
60
60
  segments:
61
61
  - 0
62
- hash: 1459145932997394850
62
+ hash: 729197856431760282
63
63
  required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  none: false
65
65
  requirements:
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  version: '0'
69
69
  segments:
70
70
  - 0
71
- hash: 1459145932997394850
71
+ hash: 729197856431760282
72
72
  requirements: []
73
73
  rubyforge_project:
74
74
  rubygems_version: 1.8.23