embulk-plugin-input-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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3d1b201c7a577eb8e4e6735ebf98889740a2a96e
4
+ data.tar.gz: b1f3c03f2fa59087d558420bcf89336ec6702d60
5
+ SHA512:
6
+ metadata.gz: 3b152eff3dca539abe2d6c49796c19b06ce174030a3c488f8b921264b163cef97f4148aeff46d0c457e5a52b1ed9505bd996fe07d892356a1388a68034878adc
7
+ data.tar.gz: 07fbdc1ed453245a940fac1fdfaea9b1a0a87c325eb6575cfa2c7f29171a10adec24efd2908f2c298f484e59bfc96ff162f1c908db8c89e8aa61280c8795ec13
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ *.swp
15
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 KUBOTA Yuji
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.
@@ -0,0 +1,42 @@
1
+ # Embulk::Plugin::Input::Jstat
2
+
3
+ [Embulk](https://github.com/embulk/embulk) input plugin for [jstat](http://docs.oracle.com/javase/8/docs/technotes/tools/unix/jstat.html).
4
+ Now, this plugin supports only JDK8.
5
+
6
+ ## Installation
7
+
8
+ Run this command with your embulk binary.
9
+
10
+ ```ruby
11
+ $ java -jar embulk.jar gem install embulk-plugin-input-jstat
12
+ ```
13
+
14
+ ## Configuration
15
+
16
+ Specify in your config.yml file
17
+
18
+ ```yaml
19
+ in:
20
+ type: jstat
21
+ paths: [/tmp, /path/to/jstat_files, /other/path/to/jstats_files]
22
+ option: -gcutil
23
+ timestamp: false
24
+ ```
25
+
26
+ - type: specify this plugin as `jstat`.
27
+ - paths: specify paths where jstat files(\*.log) are. (optional, default: /tmp)
28
+ - option: specify a stat option of jstat, e.g., -gcutil. (optional, default: -gcutil)
29
+ - timestamp: specify whether your jstat files include a timestamp column or not. (optional, default: false)
30
+
31
+ ## TODO
32
+
33
+ - support JDK7, JDK6.
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it ( https://github.com/ykubota/embulk-plugin-input-jstat/fork )
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create a new Pull Request
42
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,22 @@
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 = "embulk-plugin-input-jstat"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["KUBOTA Yuji"]
9
+ spec.email = ["kubota.yuji@gmail.com"]
10
+ spec.summary = %q{Embulk plugin for jstat input}
11
+ spec.description = spec.summary
12
+ spec.homepage = "https://github.com/ykubota/embulk-plugin-input-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.7"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ end
@@ -0,0 +1,228 @@
1
+ module Embulk
2
+ class InputJstat < InputPlugin
3
+ require 'json'
4
+
5
+ Plugin.register_input('jstat', self)
6
+
7
+ # output columns of jstat (JDK8)
8
+ JSTAT_COLUMNS = {
9
+ class: {
10
+ Loaded: 'int',
11
+ Bytes: 'double',
12
+ Unloader: 'int',
13
+ Bytes: 'double',
14
+ Time: 'double'
15
+ },
16
+ compiler: {
17
+ Compiled: 'int',
18
+ Failed: 'int',
19
+ Invalid: 'int',
20
+ Time: 'double',
21
+ FailedType: 'int',
22
+ FailedMethod: 'string'
23
+ },
24
+ gc: {
25
+ S0C: 'double',
26
+ S1C: 'double',
27
+ S0U: 'double',
28
+ S1U: 'double',
29
+ EC: 'double',
30
+ EU: 'double',
31
+ OC: 'double',
32
+ MC: 'double',
33
+ MU: 'double',
34
+ CCSC: 'double',
35
+ CCSU: 'double',
36
+ YGC: 'int',
37
+ YGCT: 'double',
38
+ FGC: 'int',
39
+ FGCT: 'double',
40
+ GCT: 'double'
41
+ },
42
+ gccause: {
43
+ S0: 'double',
44
+ S1: 'double',
45
+ E: 'double',
46
+ O: 'double',
47
+ M: 'double',
48
+ CCS: 'double',
49
+ YGC: 'int',
50
+ YGCT: 'double',
51
+ FGC: 'int',
52
+ FGCT: 'double',
53
+ GCT: 'double',
54
+ LGCC: 'string',
55
+ GCC: 'string'
56
+ },
57
+ gcnew: {
58
+ S0C: 'double',
59
+ S1C: 'double',
60
+ S0U: 'double',
61
+ S1U: 'double',
62
+ TT: 'int',
63
+ MTT: 'double',
64
+ DSS: 'double',
65
+ EC: 'double',
66
+ EU: 'double',
67
+ YGC: 'int',
68
+ YGCT: 'double'
69
+ },
70
+ gcnewcapacity: {
71
+ NGCMN: 'double',
72
+ NGCMX: 'double',
73
+ NGC: 'double',
74
+ S0CMX: 'double',
75
+ S0C: 'double',
76
+ S1CMX: 'double',
77
+ S1C: 'double',
78
+ ECMX: 'double',
79
+ EC: 'double',
80
+ YGC: 'int',
81
+ FGC: 'int'
82
+ },
83
+ gcold: {
84
+ MC: 'double',
85
+ MU: 'double',
86
+ CCSC: 'double',
87
+ CCSU: 'double',
88
+ OC: 'double',
89
+ OU: 'double',
90
+ YGC: 'int',
91
+ FGC: 'int',
92
+ FGCT: 'double',
93
+ GCT: 'double'
94
+ },
95
+ gcoldcapacity: {
96
+ OGCMN: 'double',
97
+ OGCMX: 'double',
98
+ OGC: 'double',
99
+ OC: 'double',
100
+ YGC: 'int',
101
+ FGC: 'int',
102
+ FGCT: 'double',
103
+ GCT: 'double'
104
+ },
105
+ gcmetacapacity: {
106
+ MCMN: 'double',
107
+ MCMX: 'double',
108
+ MC: 'double',
109
+ CCSMN: 'double',
110
+ CCSMX: 'double',
111
+ CCSC: 'double',
112
+ YGC: 'int',
113
+ FGC: 'int',
114
+ FGCT: 'double',
115
+ GCT: 'double'
116
+ },
117
+ gcutil: {
118
+ S0: 'double',
119
+ S1: 'double',
120
+ E: 'double',
121
+ O: 'double',
122
+ M: 'double',
123
+ CCS: 'double',
124
+ YGC: 'int',
125
+ YGCT: 'double',
126
+ FGC: 'int',
127
+ FGCT: 'double',
128
+ GCT: 'double'
129
+ },
130
+ printcompilation: {
131
+ Compiled: 'int',
132
+ Size: 'int',
133
+ Type: 'int',
134
+ Method: 'string'
135
+ }
136
+ }
137
+
138
+ def self.transaction(config, &control)
139
+ # find jstat files and push to "task".
140
+ paths = config.param('paths', :array, default: ['/tmp']).map { |path|
141
+ next [] unless Dir.exists?(path)
142
+ Dir.entries(path).sort.select{|f| f.match(/^.+\.log$/)}.map do |file|
143
+ File.expand_path(File.join(path, file))
144
+ end
145
+ }.flatten
146
+ # remove checked jstat files by other threads.
147
+ paths = paths - config.param('done', :array, default: [])
148
+ task = {'paths' => paths}
149
+
150
+ # generate schema by parsing a given options of jstat.
151
+ option = config.param('option', :string, default: 'gcutil')
152
+ option[0] = '' if option =~ /^\-/
153
+ if !JSTAT_COLUMNS.has_key?(option.to_sym)
154
+ raise "Wrong configuration: \"option: #{option}\". Specify a stat option of jstat correctly."
155
+ end
156
+
157
+ timestamp = config.param('timestamp', :bool, default: false)
158
+
159
+ i = timestamp ? 1 : 0
160
+ columns = JSTAT_COLUMNS[option.to_sym].each.with_index(i).map do |column, index|
161
+ stat, type = column
162
+ case type
163
+ when "string"
164
+ Column.new(index, stat.to_s, :string)
165
+ when "int", "long"
166
+ Column.new(index, stat.to_s, :long)
167
+ when "double", "float"
168
+ Column.new(index, stat.to_s, :double)
169
+ end
170
+ end
171
+
172
+ if timestamp
173
+ columns.unshift(Column.new(0, "Timestamp", :double))
174
+ end
175
+
176
+ #TODO: Now, force to set threads as amount of found files. Need a better idea.
177
+ report = yield(task, columns, paths.length)
178
+
179
+ config.merge( report['done'].flatten.compact )
180
+
181
+ return {}
182
+ end
183
+
184
+ def initialize(task, schema, index, page_builder)
185
+ super
186
+ end
187
+
188
+ def run
189
+ unless path = @task['paths'][@index]
190
+ return { 'done' => [] }
191
+ end
192
+
193
+ File.read(path).each_line.with_index(0) do |line, i|
194
+ stats = line.strip.split(/\s+/)
195
+
196
+ # maybe not jstat file if a number of column is not match.
197
+ if stats.size != @schema.size
198
+ # if not header, maybe injected other log, e.g. console.
199
+ i == 0 ? break : next
200
+ end
201
+
202
+ # ignore column heading line
203
+ next if i == 0 && stats[0] == @schema[0]['name']
204
+
205
+ page = []
206
+ @schema.each_with_index do |s, i|
207
+ case s['type']
208
+ when :string
209
+ page << stats[i]
210
+ # TODO: If not numeric, raise error.
211
+ when :long
212
+ page << stats[i].to_i
213
+ when :double
214
+ page << stats[i].to_f
215
+ else
216
+ raise "unknown type: #{s['type']}"
217
+ end
218
+ end
219
+ @page_builder.add(page)
220
+ end
221
+ @page_builder.finish
222
+
223
+ { # commit report
224
+ 'done' => path
225
+ }
226
+ end
227
+ end
228
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: embulk-plugin-input-jstat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - KUBOTA Yuji
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Embulk plugin for jstat input
42
+ email:
43
+ - kubota.yuji@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - embulk-plugin-input-jstat.gemspec
54
+ - lib/embulk/input_jstat.rb
55
+ homepage: https://github.com/ykubota/embulk-plugin-input-jstat
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.1.11
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Embulk plugin for jstat input
79
+ test_files: []