fluent-plugin-jstat 0.0.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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +60 -0
- data/Rakefile +1 -0
- data/fluent-plugin-jstat.gemspec +23 -0
- data/lib/fluent/plugin/in_jstat.rb +71 -0
- metadata +101 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Wataru Yukawa
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# fluent-plugin-jstat
|
2
|
+
|
3
|
+
[Fluentd](http://fluentd.org) plugin to input jstat command result.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
install with gem or fluent-gem command as:
|
7
|
+
|
8
|
+
`````
|
9
|
+
### native gem
|
10
|
+
$ gem install fluent-plugin-jstat
|
11
|
+
|
12
|
+
### fluentd gem
|
13
|
+
$ fluent-gem install fluent-plugin-jstat
|
14
|
+
`````
|
15
|
+
|
16
|
+
## Configuration
|
17
|
+
|
18
|
+
```
|
19
|
+
<source>
|
20
|
+
type jstat
|
21
|
+
option -gcutil
|
22
|
+
emit_interval 60
|
23
|
+
tag hiveserver.jstat
|
24
|
+
pid_path /var/run/hiveserver.pid
|
25
|
+
scale 1
|
26
|
+
</source>
|
27
|
+
```
|
28
|
+
|
29
|
+
#### Parameters
|
30
|
+
|
31
|
+
* option
|
32
|
+
* option for jstat command (for example, -gcutil)
|
33
|
+
* emit_interval
|
34
|
+
* emit interval second (default: 60)
|
35
|
+
* tag
|
36
|
+
* emit tag
|
37
|
+
* pid_path
|
38
|
+
* pid file path. fluent-plugin-jstat executes jstat command with process id written by thie path.
|
39
|
+
* scale
|
40
|
+
* scale jstat command resultz(default: 1)
|
41
|
+
|
42
|
+
## Output
|
43
|
+
|
44
|
+
```
|
45
|
+
2014-03-17 13:44:36 +0900 hiveserver.jstat: {"S0":0.0,"S1":0.0,"E":1.25,"O":41.29,"P":63.54,"YGC":253.0,"YGCT":1.519,"FGC":252.0,"FGCT":137.145,"GCT":138.665}
|
46
|
+
```
|
47
|
+
|
48
|
+
If you specify scale 100, the following result.
|
49
|
+
|
50
|
+
```
|
51
|
+
2014-03-17 13:44:36 +0900 hiveserver.jstat: {"S0":0.0,"S1":0.0,"E":125.0,"O":4129.0,"P":6354.0,"YGC":25300.0,"YGCT":151.9,"FGC":25200.0,"FGCT":13714.5,"GCT":13866.5}
|
52
|
+
```
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
1. Fork it ( http://github.com/wyukawa/fluent-plugin-jstat/fork )
|
57
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
58
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
59
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
60
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "fluent-plugin-jstat"
|
7
|
+
spec.version = "0.0.1"
|
8
|
+
spec.authors = ["wukawa"]
|
9
|
+
spec.email = ["wataru.yukawa@nhn.com"]
|
10
|
+
spec.summary = %q{jstat input plugin for Fluent event collector}
|
11
|
+
spec.description = %q{jstat input plugin for Fluent event collector}
|
12
|
+
spec.homepage = "https://github.com/wyukawa/fluent-plugin-jstat"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_runtime_dependency "fluentd"
|
23
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Fluent
|
2
|
+
class JstatInput < Input
|
3
|
+
Plugin.register_input('jstat', self)
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
config_param :emit_interval, :time, :default => 60
|
10
|
+
config_param :tag, :string
|
11
|
+
config_param :jstat_path, :string, :default => "jstat"
|
12
|
+
config_param :option, :string
|
13
|
+
config_param :pid_path, :string
|
14
|
+
config_param :scale, :integer, :default => 1
|
15
|
+
|
16
|
+
class TimerWatcher < Coolio::TimerWatcher
|
17
|
+
def initialize(interval, repeat, &callback)
|
18
|
+
@callback = callback
|
19
|
+
super(interval, repeat)
|
20
|
+
end
|
21
|
+
|
22
|
+
def on_timer
|
23
|
+
@callback.call
|
24
|
+
rescue
|
25
|
+
# TODO log?
|
26
|
+
$log.error $!.to_s
|
27
|
+
$log.error_backtrace
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def configure(conf)
|
32
|
+
super
|
33
|
+
@pid = File.read(@pid_path)
|
34
|
+
@command = "#{@jstat_path} #{@option} #{@pid}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def start
|
38
|
+
@loop = Coolio::Loop.new
|
39
|
+
@timer = TimerWatcher.new(@emit_interval, true, &method(:on_timer))
|
40
|
+
@loop.attach(@timer)
|
41
|
+
@thread = Thread.new(&method(:run))
|
42
|
+
end
|
43
|
+
|
44
|
+
def shutdown
|
45
|
+
@loop.watchers.each {|w| w.detach }
|
46
|
+
@loop.stop
|
47
|
+
@thread.join
|
48
|
+
end
|
49
|
+
|
50
|
+
def run
|
51
|
+
@loop.run
|
52
|
+
rescue
|
53
|
+
$log.error "unexpected error", :error=>$!.to_s
|
54
|
+
$log.error_backtrace
|
55
|
+
end
|
56
|
+
|
57
|
+
def on_timer
|
58
|
+
now = Engine.now
|
59
|
+
io = IO.popen(@command, "r")
|
60
|
+
lines = io.readlines()
|
61
|
+
headers = lines[0].split()
|
62
|
+
datas = lines[1].split()
|
63
|
+
|
64
|
+
record = Hash.new
|
65
|
+
headers.each_with_index{|header, i|
|
66
|
+
record[header] = datas[i].to_f * @scale
|
67
|
+
}
|
68
|
+
Engine.emit(@tag, now, record)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-jstat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- wukawa
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-03-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.5'
|
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: '1.5'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
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
|
+
description: jstat input plugin for Fluent event collector
|
63
|
+
email:
|
64
|
+
- wataru.yukawa@nhn.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- fluent-plugin-jstat.gemspec
|
75
|
+
- lib/fluent/plugin/in_jstat.rb
|
76
|
+
homepage: https://github.com/wyukawa/fluent-plugin-jstat
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.8.23.2
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: jstat input plugin for Fluent event collector
|
101
|
+
test_files: []
|