fluent-plugin-ganglia 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/README.rdoc +87 -0
- data/Rakefile +8 -0
- data/fluent-plugin-ganglia.gemspec +22 -0
- data/lib/fluent/plugin/out_ganglia.rb +106 -0
- data/test/helper.rb +28 -0
- data/test/plugin/test_out_ganglia.rb +24 -0
- data/test/plugins.rb +35 -0
- metadata +121 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
= fluent-plugin-ganglia
|
2
|
+
|
3
|
+
Plugin to output values to Ganglia.
|
4
|
+
|
5
|
+
= Configuration
|
6
|
+
|
7
|
+
* type
|
8
|
+
* required "ganglia"
|
9
|
+
* name_keys or name_key_pattern
|
10
|
+
* required
|
11
|
+
* specify key name by _name_keys_ or regexp pattern of keys by _name_key_pattern_
|
12
|
+
* add_key_prefix
|
13
|
+
* string to add key prefix
|
14
|
+
* host
|
15
|
+
* host to send metric (default=127.0.0.1)
|
16
|
+
* post
|
17
|
+
* port of host to send metric (default=8649)
|
18
|
+
* value_type
|
19
|
+
* type of value
|
20
|
+
* same as gmetric --type
|
21
|
+
* units
|
22
|
+
* unit of value
|
23
|
+
* same as gemtric --units
|
24
|
+
* group
|
25
|
+
* metric group
|
26
|
+
* same as gemtric --group
|
27
|
+
* title
|
28
|
+
* metric title
|
29
|
+
* same as gemtric --title
|
30
|
+
* tmax
|
31
|
+
* maximum time in seconds between gmetric calls. (default=60)
|
32
|
+
* same as gemtric --tmax
|
33
|
+
* dmax
|
34
|
+
* lifetime in seconds of this metric. (default=0)
|
35
|
+
* same as gemtric --dmax
|
36
|
+
* slope
|
37
|
+
* Either zero|positive|negative|both. (default=both)
|
38
|
+
* same as gemtric --slope
|
39
|
+
* spoof
|
40
|
+
* IP address and name of host/device we are spoofing. (default=nil)
|
41
|
+
* same as gmetric --spooof
|
42
|
+
* bind_hostname
|
43
|
+
* whether upd_send_channel.bind_hostname is yes(true) or no(fale). (default=false)
|
44
|
+
|
45
|
+
= Example
|
46
|
+
|
47
|
+
== gmond configured with multicast
|
48
|
+
|
49
|
+
when the gmond configured with multicast and bind_hostname as below:
|
50
|
+
|
51
|
+
udp_send_channel {
|
52
|
+
mcast_join = 239.2.11.71
|
53
|
+
bind_hostname = yes
|
54
|
+
port = 8640
|
55
|
+
...
|
56
|
+
}
|
57
|
+
|
58
|
+
you should specify mcast_join ip address to _host_ and set _bind__hostname_ true:
|
59
|
+
|
60
|
+
<match metrics>
|
61
|
+
type ganglia
|
62
|
+
host 239.2.11.71
|
63
|
+
port 8649
|
64
|
+
group metric_group
|
65
|
+
name_keys metrics.field1,metrics.field2
|
66
|
+
bind_hostname true
|
67
|
+
</match>
|
68
|
+
|
69
|
+
== gmond configured with unicast
|
70
|
+
|
71
|
+
when the gmond configured with unicast, you should specify _host_ and _port_ with same value of gmond.conf:
|
72
|
+
|
73
|
+
<match metrics>
|
74
|
+
type ganglia
|
75
|
+
host 192.0.2.100
|
76
|
+
port 8649
|
77
|
+
group metric_group
|
78
|
+
name_key_pattern ^field
|
79
|
+
</match>
|
80
|
+
|
81
|
+
= License
|
82
|
+
|
83
|
+
Apache License, Version 2.0
|
84
|
+
|
85
|
+
= Copyright
|
86
|
+
|
87
|
+
Copyright (c) 2013 Hiroshi Sakai
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- mode:ruby -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = "fluent-plugin-ganglia"
|
5
|
+
gem.version = "0.0.1"
|
6
|
+
gem.authors = ["Hiroshi Sakai"]
|
7
|
+
gem.email = ["ziguzagu@gmail.com"]
|
8
|
+
gem.description = %q{Fluentd output plugin to ganglia}
|
9
|
+
gem.summary = %q{Fluentd output plugin to ganglia}
|
10
|
+
gem.homepage = "https://github.com/ziguzagu/fluent-plugin-ganglia"
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
|
17
|
+
gem.add_development_dependency "rake"
|
18
|
+
gem.add_development_dependency "fluentd"
|
19
|
+
|
20
|
+
gem.add_runtime_dependency "fluentd"
|
21
|
+
gem.add_runtime_dependency "gmetric"
|
22
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
class Fluent::GangliaOutput < Fluent::Output
|
2
|
+
Fluent::Plugin.register_output('ganglia', self)
|
3
|
+
|
4
|
+
HOSTNAME = Socket.gethostname
|
5
|
+
HOSTADDR = IPSocket.getaddress(HOSTNAME)
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
require "gmetric"
|
10
|
+
require "socket"
|
11
|
+
end
|
12
|
+
|
13
|
+
config_param :port, :integer, :default => 8649
|
14
|
+
config_param :host, :string, :default => '127.0.0.1'
|
15
|
+
config_param :name_keys, :string, :default => nil
|
16
|
+
config_param :name_key_pattern, :string, :default => nil
|
17
|
+
config_param :add_key_prefix, :string, :default => nil
|
18
|
+
config_param :value_type, :string, :default => 'uint32'
|
19
|
+
config_param :units, :string, :default => ''
|
20
|
+
config_param :group, :string, :default => ''
|
21
|
+
config_param :title, :string, :default => ''
|
22
|
+
config_param :tmax, :integer, :default => 60
|
23
|
+
config_param :dmax, :integer, :default => 0
|
24
|
+
config_param :slope, :string, :default => 'both'
|
25
|
+
config_param :spoof, :string, :default => nil
|
26
|
+
config_param :bind_hostname, :bool, :default => false
|
27
|
+
|
28
|
+
def configure(conf)
|
29
|
+
super
|
30
|
+
|
31
|
+
if @name_keys.nil? and @name_key_pattern.nil?
|
32
|
+
raise Fluent::ConfigError, "missing both of name_keys and name_key_pattern"
|
33
|
+
end
|
34
|
+
if not @name_keys.nil? and not @name_key_pattern.nil?
|
35
|
+
raise Fluent::ConfigError, "cannot specify both of name_keys and name_key_pattern"
|
36
|
+
end
|
37
|
+
if @name_keys
|
38
|
+
@name_keys = @name_keys.split(/ *, */)
|
39
|
+
end
|
40
|
+
if @name_key_pattern
|
41
|
+
@name_key_pattern = Regexp.new(@name_key_pattern)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def start
|
46
|
+
super
|
47
|
+
end
|
48
|
+
|
49
|
+
def shutdown
|
50
|
+
super
|
51
|
+
end
|
52
|
+
|
53
|
+
def send(tag, name, value, time)
|
54
|
+
if @add_key_prefix
|
55
|
+
name = "#{@add_key_prefix} #{name}"
|
56
|
+
end
|
57
|
+
begin
|
58
|
+
$log.debug("ganglia: #{name}: #{value}, ts: #{time}")
|
59
|
+
gmetric = Ganglia::GMetric.pack(
|
60
|
+
:name => name,
|
61
|
+
:value => value.to_s,
|
62
|
+
:type => @value_type,
|
63
|
+
:units => @units,
|
64
|
+
:tmax => @tmax,
|
65
|
+
:dmax => @dmax,
|
66
|
+
:title => @title,
|
67
|
+
:group => @group,
|
68
|
+
:slope => @slope,
|
69
|
+
:spoof => @spoof ? 1 : 0,
|
70
|
+
:hostname => @spoof ? @spoof : HOSTNAME,
|
71
|
+
)
|
72
|
+
conn = UDPSocket.new
|
73
|
+
conn.bind(HOSTADDR, 0) if @bind_hostname
|
74
|
+
conn.send gmetric[0], 0, @host, @port
|
75
|
+
conn.send gmetric[1], 0, @host, @port
|
76
|
+
conn.close
|
77
|
+
status = true
|
78
|
+
rescue IOError, EOFError, SystemCallError
|
79
|
+
$log.warn "Ganglia::GMetric.send raises exception: #{$!.class}, '#{$!.message}'"
|
80
|
+
end
|
81
|
+
unless status
|
82
|
+
$log.warn "failed to send to ganglia: #{@host}:#{@port}, '#{name}': #{value}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def emit(tag, es, chain)
|
87
|
+
if @name_keys
|
88
|
+
es.each {|time,record|
|
89
|
+
@name_keys.each {|name|
|
90
|
+
if record[name]
|
91
|
+
send(tag, name, record[name], time)
|
92
|
+
end
|
93
|
+
}
|
94
|
+
}
|
95
|
+
else # for name_key_pattern
|
96
|
+
es.each {|time,record|
|
97
|
+
record.keys.each {|key|
|
98
|
+
if @name_key_pattern.match(key) and record[key]
|
99
|
+
send(tag, key, record[key], time)
|
100
|
+
end
|
101
|
+
}
|
102
|
+
}
|
103
|
+
end
|
104
|
+
chain.next
|
105
|
+
end
|
106
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
require 'fluent/test'
|
15
|
+
unless ENV.has_key?('VERBOSE')
|
16
|
+
nulllogger = Object.new
|
17
|
+
nulllogger.instance_eval {|obj|
|
18
|
+
def method_missing(method, *args)
|
19
|
+
# pass
|
20
|
+
end
|
21
|
+
}
|
22
|
+
$log = nulllogger
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'fluent/plugin/out_ganglia'
|
26
|
+
|
27
|
+
class Test::Unit::TestCase
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class GangliaOutputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Fluent::Test.setup
|
6
|
+
end
|
7
|
+
|
8
|
+
CONFIG = %[
|
9
|
+
port 8649
|
10
|
+
add_key_prefix test
|
11
|
+
name_keys foo, bar, baz
|
12
|
+
]
|
13
|
+
|
14
|
+
def create_driver(conf = CONFIG, tag='test')
|
15
|
+
Fluent::Test::OutputTestDriver.new(Fluent::GangliaOutput, tag).configure(conf)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_write
|
19
|
+
# d = create_driver
|
20
|
+
# d.emit({"foo" => "test value of foo"})
|
21
|
+
# d.emit({"bar" => "test value of bar"})
|
22
|
+
# d.emit({"baz" => rand * 10 })
|
23
|
+
end
|
24
|
+
end
|
data/test/plugins.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
class Fluent::GangliaTestInput < Fluent::Input
|
2
|
+
Fluent::Plugin.register_input('ganglia_test', self)
|
3
|
+
config_param :port
|
4
|
+
config_param :host
|
5
|
+
config_param :name_keys
|
6
|
+
config_param :name_key_pattern
|
7
|
+
config_param :add_key_prefix
|
8
|
+
config_param :value_type
|
9
|
+
config_param :units
|
10
|
+
config_param :group
|
11
|
+
config_param :title
|
12
|
+
config_param :tmax
|
13
|
+
config_param :dmax
|
14
|
+
config_param :slope
|
15
|
+
config_param :spoof
|
16
|
+
config_param :bind_hostname
|
17
|
+
end
|
18
|
+
|
19
|
+
class Fluent::GangliaTestOutput < Fluent::Output
|
20
|
+
Fluent::Plugin.register_output('ganglia_test', self)
|
21
|
+
config_param :port
|
22
|
+
config_param :host
|
23
|
+
config_param :name_keys
|
24
|
+
config_param :name_key_pattern
|
25
|
+
config_param :add_key_prefix
|
26
|
+
config_param :value_type
|
27
|
+
config_param :units
|
28
|
+
config_param :group
|
29
|
+
config_param :title
|
30
|
+
config_param :tmax
|
31
|
+
config_param :dmax
|
32
|
+
config_param :slope
|
33
|
+
config_param :spoof
|
34
|
+
config_param :bind_hostname
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-ganglia
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Hiroshi Sakai
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: fluentd
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: fluentd
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: gmetric
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: Fluentd output plugin to ganglia
|
79
|
+
email:
|
80
|
+
- ziguzagu@gmail.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- Gemfile
|
87
|
+
- README.rdoc
|
88
|
+
- Rakefile
|
89
|
+
- fluent-plugin-ganglia.gemspec
|
90
|
+
- lib/fluent/plugin/out_ganglia.rb
|
91
|
+
- test/helper.rb
|
92
|
+
- test/plugin/test_out_ganglia.rb
|
93
|
+
- test/plugins.rb
|
94
|
+
homepage: https://github.com/ziguzagu/fluent-plugin-ganglia
|
95
|
+
licenses: []
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 1.8.24
|
115
|
+
signing_key:
|
116
|
+
specification_version: 3
|
117
|
+
summary: Fluentd output plugin to ganglia
|
118
|
+
test_files:
|
119
|
+
- test/helper.rb
|
120
|
+
- test/plugin/test_out_ganglia.rb
|
121
|
+
- test/plugins.rb
|