rb_jstat2gf 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +26 -0
- data/Rakefile +2 -0
- data/bin/rb_jstat2gf +109 -0
- data/lib/rb_jstat2gf/version.rb +3 -0
- data/rb_jstat2gf.gemspec +24 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4d57cf2d742adfe2dab7df768046a2b7a031a2b6
|
4
|
+
data.tar.gz: 34e3376d4dc0351e6450c2291049a4c39877e0f1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cc0de511240f59b00ae0518be2b9312fe502627a643da93af421e5a1ef65bd5ae4385f8bdf82d8c4e3fbaa273426a1f607cdf873fac2252df048a7003d24a9b3
|
7
|
+
data.tar.gz: 6d5841ebdf2ebf7dfe7daa3a8ef910afa6264886b9609859ab1853c6a883df1623d3ee1c95799c82cc58bcb261701e19cb221b9b8ba9207171ab65eb29e333aa
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 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,26 @@
|
|
1
|
+
# rb_jstat2gf
|
2
|
+
|
3
|
+
It is a Ruby clone of jstat2gf(https://github.com/kazeburo/jstat2gf)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```
|
8
|
+
$ gem install rb_jstat2gf
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
```
|
14
|
+
$ rb_jstat2gf --url=your.gf.host.name --port=5125 --service=aaa --section=hive --prefix=hs2 --pid=$(pgrep -of HiveServer2)
|
15
|
+
```
|
16
|
+
|
17
|
+
## Requirements
|
18
|
+
* Java 8
|
19
|
+
|
20
|
+
## Contributing
|
21
|
+
|
22
|
+
1. Fork it ( https://github.com/wyukawa/rb_jstat2gf/fork )
|
23
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
24
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
25
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
26
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/rb_jstat2gf
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
require "rb_jstat2gf/version"
|
2
|
+
require 'optparse'
|
3
|
+
require 'growthforecast'
|
4
|
+
|
5
|
+
def exec_jstat(option, pid)
|
6
|
+
jstat_path="jstat"
|
7
|
+
command = "#{jstat_path} #{option} #{pid}"
|
8
|
+
io = IO.popen(command, "r")
|
9
|
+
lines = io.readlines()
|
10
|
+
io.close
|
11
|
+
headers = lines[0].split()
|
12
|
+
datas = lines[1].split()
|
13
|
+
|
14
|
+
record = Hash.new
|
15
|
+
headers.each_with_index{|header, i|
|
16
|
+
record[header] = datas[i].to_f
|
17
|
+
}
|
18
|
+
|
19
|
+
record
|
20
|
+
end
|
21
|
+
|
22
|
+
option={}
|
23
|
+
OptionParser.new do |opt|
|
24
|
+
opt.on("--url=url", "") {|v| option[:url] = v}
|
25
|
+
opt.on("--port=port", "") {|v| option[:port] = v}
|
26
|
+
opt.on("--service=service", "") {|v| option[:service] = v}
|
27
|
+
opt.on("--section=section", "") {|v| option[:section] = v}
|
28
|
+
opt.on("--prefix=prefix", "") {|v| option[:prefix] = v}
|
29
|
+
opt.on("--pid=pid", "") {|v| option[:pid] = v}
|
30
|
+
|
31
|
+
opt.parse!(ARGV)
|
32
|
+
end
|
33
|
+
|
34
|
+
url = option[:url]
|
35
|
+
port = option[:port]
|
36
|
+
service = option[:service]
|
37
|
+
section = option[:section]
|
38
|
+
prefix = option[:prefix]
|
39
|
+
pid = option[:pid]
|
40
|
+
|
41
|
+
gccapacity = exec_jstat("-gccapacity", pid)
|
42
|
+
gcold = exec_jstat("-gcold", pid)
|
43
|
+
gcnew = exec_jstat("-gcnew", pid)
|
44
|
+
gc = exec_jstat("-gc", pid)
|
45
|
+
|
46
|
+
gf = GrowthForecast.new(url, port)
|
47
|
+
|
48
|
+
new_max = gf.post(service, section, prefix + "_new_max", gccapacity["NGCMX"].to_i, 'gauge', '#1111cc')
|
49
|
+
new_commit = gf.post(service, section, prefix + "_new_commit", gccapacity["NGC"].to_i, 'gauge', '#11cc11')
|
50
|
+
old_max = gf.post(service, section, prefix + "_old_max", gccapacity["OGCMX"].to_i, 'gauge', '#1111cc')
|
51
|
+
old_commit = gf.post(service, section, prefix + "_old_commit", gccapacity["OGC"].to_i, 'gauge', '#11cc11')
|
52
|
+
meta_max = gf.post(service, section, prefix + "_meta_max", gccapacity["MCMX"].to_i, 'gauge', '#1111cc')
|
53
|
+
meta_commit = gf.post(service, section, prefix + "_meta_commit", gccapacity["MC"].to_i, 'gauge', '#11cc11')
|
54
|
+
|
55
|
+
meta_used = gf.post(service, section, prefix + "_meta_used", gcold["MU"].to_i, 'gauge', '#cccc77')
|
56
|
+
old_used = gf.post(service, section, prefix + "_old_used", gcold["OU"].to_i, 'gauge', '#cccc77')
|
57
|
+
|
58
|
+
sv0_used = gf.post(service, section, prefix + "_sv0_used", gcnew["S0U"].to_i, 'gauge', '#952d57')
|
59
|
+
sv1_used = gf.post(service, section, prefix + "_sv1_used", gcnew["S1U"].to_i, 'gauge', '#f9d475')
|
60
|
+
eden_used = gf.post(service, section, prefix + "_eden_used", gcnew["EU"].to_i, 'gauge', '#dd923c')
|
61
|
+
|
62
|
+
fgc_times = gf.post(service, section, prefix + "_fgc_times", gc["FGC"].to_i, 'gauge', '#7020AF')
|
63
|
+
fgc_sec = gf.post(service, section, prefix + "_fgc_sec", gc["FGCT"]*1000, 'gauge', '#F0B300')
|
64
|
+
|
65
|
+
complex_new = GrowthForecast::Complex.new({
|
66
|
+
complex: true,
|
67
|
+
service_name: service, section_name: section, graph_name: prefix + "_new",
|
68
|
+
description: "JVM memory KB (new)",
|
69
|
+
sort: 19
|
70
|
+
})
|
71
|
+
new_commit_item = GrowthForecast::Complex::Item.new({graph_id: new_commit.id, type: 'AREA', gmode: 'gauge', stack: false})
|
72
|
+
complex_new.data.push(new_commit_item)
|
73
|
+
new_max_item = GrowthForecast::Complex::Item.new({graph_id: new_max.id, type: 'LINE1', gmode: 'gauge', stack: false})
|
74
|
+
complex_new.data.push(new_max_item)
|
75
|
+
sv0_used_item = GrowthForecast::Complex::Item.new({graph_id: sv0_used.id, type: 'AREA', gmode: 'gauge', stack: false})
|
76
|
+
complex_new.data.push(sv0_used_item)
|
77
|
+
sv1_used_item = GrowthForecast::Complex::Item.new({graph_id: sv1_used.id, type: 'AREA', gmode: 'gauge', stack: true})
|
78
|
+
complex_new.data.push(sv1_used_item)
|
79
|
+
eden_used_item = GrowthForecast::Complex::Item.new({graph_id: eden_used.id, type: 'AREA', gmode: 'gauge', stack: true})
|
80
|
+
complex_new.data.push(eden_used_item)
|
81
|
+
gf.add(complex_new)
|
82
|
+
|
83
|
+
complex_metaspace = GrowthForecast::Complex.new({
|
84
|
+
complex: true,
|
85
|
+
service_name: service, section_name: section, graph_name: prefix + "_metaspace",
|
86
|
+
description: "JVM memory KB (metaspace)",
|
87
|
+
sort: 17
|
88
|
+
})
|
89
|
+
meta_commit_item = GrowthForecast::Complex::Item.new({graph_id: meta_commit.id, type: 'AREA', gmode: 'gauge', stack: false})
|
90
|
+
complex_metaspace.data.push(meta_commit_item)
|
91
|
+
meta_max_item = GrowthForecast::Complex::Item.new({graph_id: meta_max.id, type: 'LINE1', gmode: 'gauge', stack: false})
|
92
|
+
complex_metaspace.data.push(meta_max_item)
|
93
|
+
meta_used_item = GrowthForecast::Complex::Item.new({graph_id: meta_used.id, type: 'AREA', gmode: 'gauge', stack: false})
|
94
|
+
complex_metaspace.data.push(meta_used_item)
|
95
|
+
gf.add(complex_metaspace)
|
96
|
+
|
97
|
+
complex_old = GrowthForecast::Complex.new({
|
98
|
+
complex: true,
|
99
|
+
service_name: service, section_name: section, graph_name: prefix + "_old",
|
100
|
+
description: "JVM memory KB (old)",
|
101
|
+
sort: 18
|
102
|
+
})
|
103
|
+
old_commit_item = GrowthForecast::Complex::Item.new({graph_id: old_commit.id, type: 'AREA', gmode: 'gauge', stack: false})
|
104
|
+
complex_old.data.push(old_commit_item)
|
105
|
+
old_max_item = GrowthForecast::Complex::Item.new({graph_id: old_max.id, type: 'LINE1', gmode: 'gauge', stack: false})
|
106
|
+
complex_old.data.push(old_max_item)
|
107
|
+
old_used_item = GrowthForecast::Complex::Item.new({graph_id: old_used.id, type: 'AREA', gmode: 'gauge', stack: false})
|
108
|
+
complex_old.data.push(old_used_item)
|
109
|
+
gf.add(complex_old)
|
data/rb_jstat2gf.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rb_jstat2gf/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rb_jstat2gf"
|
8
|
+
spec.version = RbJstat2gf::VERSION
|
9
|
+
spec.authors = ["wyukawa"]
|
10
|
+
spec.email = ["wyukawa@gmail.com"]
|
11
|
+
spec.summary = %q{It is a Ruby clone of jstat2gf}
|
12
|
+
spec.description = %q{post jstat metrics to GrowthForecast}
|
13
|
+
spec.homepage = "https://github.com/wyukawa/rb_jstat2gf"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_runtime_dependency "growthforecast"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rb_jstat2gf
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- wyukawa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-11 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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: growthforecast
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: post jstat metrics to GrowthForecast
|
56
|
+
email:
|
57
|
+
- wyukawa@gmail.com
|
58
|
+
executables:
|
59
|
+
- rb_jstat2gf
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/rb_jstat2gf
|
69
|
+
- lib/rb_jstat2gf/version.rb
|
70
|
+
- rb_jstat2gf.gemspec
|
71
|
+
homepage: https://github.com/wyukawa/rb_jstat2gf
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.2.2
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: It is a Ruby clone of jstat2gf
|
95
|
+
test_files: []
|