riemann-hadoop 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 11385797da4eed173b08ea7bd7ff9c8f4eeec172
4
+ data.tar.gz: 960ed0835e98fb9626721f9201a130a22cdfba17
5
+ SHA512:
6
+ metadata.gz: 8b29dfd2f7d238d3949af9a62c29545c7d409c809920cbbc313742388927100af83e9764cc6c81fe1b1ac0142c271a7879bbcebd41a8c3cc5a0901db53e5ea8b
7
+ data.tar.gz: 5f7a476317c46b19718b2890913cab298c24e83a871f0362940a649eff280c0c7fe2bd41bc0cefc01d583acd49958c279f45c74ebf6a5c7453d980eea21d4602
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011 Kyle Kingsbury
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ Riemann Hadoop
2
+ =============
3
+
4
+ Riemann client for Hadoop Namenode and Datanode.
5
+
6
+ Both the clients pull metrics from Apache Hadoop's /jmx endpoint.
7
+
8
+ **Note: It requires Apache Hadoop 1.0+ or Hadoop 2.0+.**
9
+
10
+ Get started
11
+ ==========
12
+
13
+ ``` bash
14
+ gem install riemann-hadoop
15
+ riemann-hadoop-datanode --help
16
+ riemann-hadoop-namenode --help
17
+ ```
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Gather statistics from Apache Hadoop Datanode's jmx page and submits it to Riemann.
4
+ # It requires Apache Hadoop 1.0+ or Hadoop 2.0+.
5
+
6
+ require 'riemann/tools'
7
+
8
+ class Riemann::Tools::HadoopDataNode
9
+ include Riemann::Tools
10
+ require 'net/http'
11
+ require 'rubygems'
12
+ require 'json'
13
+
14
+ opt :datanode_host, "Hadoop Datanode hostname", :default => `hostname`.chomp
15
+ opt :datanode_port, "Hadoop Datanode port", :default => '50075'
16
+ opt :datanode_jmx_url, "Hadoop Datanode's /jmx endpoint", :default => '/jmx'
17
+
18
+ def initialize
19
+ @uri = URI('http://' + opts[:datanode_host] + ':' + opts[:datanode_port] + opts[:datanode_jmx_url])
20
+ end
21
+
22
+ def tick
23
+ json = JSON.parse(get_json.body)['beans']
24
+
25
+ for bean in json do
26
+ if (! bean.has_key? 'name') or (! bean['name'].include? "name=")
27
+ next
28
+ end
29
+
30
+ context = bean['name'].split('name=')[1].split(",sub=")
31
+ context.map!{|c|
32
+ c.downcase.tr(" ","_")
33
+ }
34
+
35
+ bean.each do |key,value|
36
+ if !value.is_a? Fixnum
37
+ next
38
+ end
39
+
40
+ report(
41
+ :host => opts[:datanode_host],
42
+ :service => "hadoop.datanode." + context.join(".") + "." + key.downcase,
43
+ :metric => value.to_f,
44
+ :state => "ok",
45
+ :tags => ["Hadoop Datanode"]
46
+ )
47
+ end
48
+ end
49
+ end
50
+
51
+ def get_json
52
+ uri = URI(@uri)
53
+ Net::HTTP.start(uri.host, uri.port) do |http|
54
+ request = Net::HTTP::Get.new uri
55
+ response = http.request request
56
+ end
57
+ end
58
+ end
59
+
60
+ Riemann::Tools::HadoopDataNode.run
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Gather statistics from Apache Hadoop Namenode's jmx page and submits it to Riemann.
4
+ # It requires Apache Hadoop 1.0+ or Hadoop 2.0+.
5
+
6
+ require 'riemann/tools'
7
+
8
+ class Riemann::Tools::HadoopNameNode
9
+ include Riemann::Tools
10
+ require 'net/http'
11
+ require 'rubygems'
12
+ require 'json'
13
+
14
+ opt :namenode_host, "Hadoop Namenode hostname", :default => `hostname`.chomp
15
+ opt :namenode_port, "Hadoop Namenode port", :default => '50070'
16
+ opt :namenode_jmx_url, "Hadoop Namenode's /jmx endpoint", :default => '/jmx'
17
+
18
+ def initialize
19
+ @uri = URI('http://' + opts[:namenode_host] + ':' + opts[:namenode_port] + opts[:namenode_jmx_url])
20
+ end
21
+
22
+ def tick
23
+ json = JSON.parse(get_json.body)['beans']
24
+ for bean in json do
25
+ if (! bean.has_key? 'name') or (! bean['name'].include? "name=")
26
+ next
27
+ end
28
+ context = bean['name'].split('name=')[1].split(",sub=")
29
+ context.map!{|c|
30
+ c.downcase.tr(" ","_")
31
+ }
32
+
33
+ bean.each do |key,value|
34
+ if !value.is_a? Fixnum
35
+ next
36
+ end
37
+ report(
38
+ :host => opts[:namenode_host],
39
+ :service => "hadoop.namenode." + context.join(".") + "." + key.downcase,
40
+ :metric => value.to_f,
41
+ :state => "ok",
42
+ :tags => ["Hadoop Namenode"]
43
+ )
44
+ end
45
+ end
46
+ end
47
+
48
+ def get_json
49
+ uri = URI(@uri)
50
+ Net::HTTP.start(uri.host, uri.port) do |http|
51
+ request = Net::HTTP::Get.new uri
52
+ response = http.request request
53
+ end
54
+ end
55
+ end
56
+
57
+ Riemann::Tools::HadoopNameNode.run
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: riemann-hadoop
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Pradeep Chhetri
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: riemann-tools
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.1
27
+ description:
28
+ email: pradeep.chhetri89@gmail.com
29
+ executables:
30
+ - riemann-hadoop-datanode
31
+ - riemann-hadoop-namenode
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - bin/riemann-hadoop-datanode
36
+ - bin/riemann-hadoop-namenode
37
+ - LICENSE
38
+ - README.md
39
+ homepage: https://github.com/riemann/riemann-hadoop
40
+ licenses: []
41
+ metadata: {}
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - '>='
49
+ - !ruby/object:Gem::Version
50
+ version: 2.0.0
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project: riemann-hadoop
58
+ rubygems_version: 2.0.14
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: Collect jmx stats for Hadoop Namenode and Datanode and submits them to Riemann.
62
+ test_files: []