jrmonitor 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +7 -0
  2. data/jrmonitor.gemspec +26 -0
  3. data/jruby-ext/target/classes/com/purbon/jrmonitor/JRMonitorService$1.class +0 -0
  4. data/jruby-ext/target/classes/com/purbon/jrmonitor/JRMonitorService$2.class +0 -0
  5. data/jruby-ext/target/classes/com/purbon/jrmonitor/JRMonitorService$3.class +0 -0
  6. data/jruby-ext/target/classes/com/purbon/jrmonitor/JRMonitorService$4.class +0 -0
  7. data/jruby-ext/target/classes/com/purbon/jrmonitor/JRMonitorService.class +0 -0
  8. data/jruby-ext/target/classes/com/purbon/jrmonitor/JRubyUtils.class +0 -0
  9. data/jruby-ext/target/classes/com/purbon/jrmonitor/monitors/HotThreadsMonitor$1.class +0 -0
  10. data/jruby-ext/target/classes/com/purbon/jrmonitor/monitors/HotThreadsMonitor$ThreadReport.class +0 -0
  11. data/jruby-ext/target/classes/com/purbon/jrmonitor/monitors/HotThreadsMonitor.class +0 -0
  12. data/jruby-ext/target/classes/com/purbon/jrmonitor/monitors/MemoryMonitor$Report.class +0 -0
  13. data/jruby-ext/target/classes/com/purbon/jrmonitor/monitors/MemoryMonitor$Type.class +0 -0
  14. data/jruby-ext/target/classes/com/purbon/jrmonitor/monitors/MemoryMonitor.class +0 -0
  15. data/jruby-ext/target/classes/com/purbon/jrmonitor/monitors/ProcessMonitor$Report.class +0 -0
  16. data/jruby-ext/target/classes/com/purbon/jrmonitor/monitors/ProcessMonitor.class +0 -0
  17. data/jruby-ext/target/classes/com/purbon/jrmonitor/monitors/SystemMonitor$Report.class +0 -0
  18. data/jruby-ext/target/classes/com/purbon/jrmonitor/monitors/SystemMonitor.class +0 -0
  19. data/jruby-ext/target/classes/com/purbon/jrmonitor/reports/RubyMemoryReport.class +0 -0
  20. data/jruby-ext/target/classes/com/purbon/jrmonitor/reports/RubyProcessReport.class +0 -0
  21. data/jruby-ext/target/classes/com/purbon/jrmonitor/reports/RubySystemReport.class +0 -0
  22. data/jruby-ext/target/classes/com/purbon/jrmonitor/reports/RubyThreadsReport.class +0 -0
  23. data/lib/jrmonitor.rb +24 -0
  24. data/lib/jrmonitor/version.rb +3 -0
  25. data/spec/lib/memory_monitor_spec.rb +37 -0
  26. data/spec/lib/process_monitor_spec.rb +40 -0
  27. data/spec/lib/system_monitor_spec.rb +27 -0
  28. data/spec/lib/thread_monitor_spec.rb +105 -0
  29. data/spec/spec_helper.rb +2 -0
  30. metadata +129 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8a65837362b154244853b7a9bc93d47aa82532bb
4
+ data.tar.gz: 0dfaa4c267fc28bdc0374368d9f5d77bb0d51cc5
5
+ SHA512:
6
+ metadata.gz: 154cce4899bd45a301cac1234f8f9a74141bd19d431bd36e5663861c5b7bb3625c222e1d28c5c1239b324824f53209068d534283a1136ad3270b458882478481
7
+ data.tar.gz: a9f50535c8399f1267f65debd7bca63c2fbd1d4beeee577888e40dc26163328edb4975126fa6a7b787af45c8ebd3c157780161ab9cfbf8b43403aa330801bd5f
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'monitoring/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jrmonitor"
8
+ spec.version = "0.4.1"
9
+ spec.authors = ["Elastic"]
10
+ spec.email = ["info@elastic.co"]
11
+
12
+ spec.summary = %q{JVM Platform MXBeans wrapper used for monitoring.}
13
+ spec.description = %q{This gems allows you to access in a Ruby friendly way the internal JVM monitoring tools for things like System, Threads and Memory information}
14
+ spec.homepage = "http://www.purbon.com"
15
+ spec.license = "Apache License (2.0)"
16
+
17
+ spec.files = Dir.glob(["jrmonitor.gemspec", "lib/**/*.rb", "spec/**/*.rb", "jruby-ext/target/classes/**/*.class"])
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib", "jruby-ext"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "pry", "~> 0.10.1"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec"
26
+ end
@@ -0,0 +1,24 @@
1
+ require "java"
2
+ $CLASSPATH << File.join(File.dirname(__FILE__), "..", "jruby-ext", "target", "classes")
3
+
4
+ require "monitoring/version"
5
+ require "com/purbon/jrmonitor/JRMonitor"
6
+
7
+ module JRMonitor
8
+
9
+ def self.threads
10
+ Report::Threads.new
11
+ end
12
+
13
+ def self.system
14
+ Report::System.new
15
+ end
16
+
17
+ def self.memory
18
+ Report::Memory.new
19
+ end
20
+
21
+ def self.process
22
+ Report::Process.new
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module JRMonitor
2
+ VERSION = "0.4.1"
3
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe JRMonitor::Report::Memory do
4
+
5
+ let(:report) { subject.generate }
6
+
7
+ it 'pulls usage for heap and non heap memory' do
8
+ expect(report.keys).to include("heap")
9
+ expect(report.keys).to include("non_heap")
10
+ end
11
+
12
+ context "#heap memory"do
13
+
14
+ let(:report) { subject.generate_with_heap }
15
+
16
+ it "pull usage for each space" do
17
+ spaces = ["PS Survivor Space", "PS Old Gen", "PS Eden Space"]
18
+ report.keys.each do |space|
19
+ expect(spaces).to include(space);
20
+ end
21
+ end
22
+
23
+ it "pull usage and peak info for each space" do
24
+ report.each_pair do |_, values|
25
+ expect(values).to include("usage.used" => kind_of(Fixnum))
26
+ expect(values).to include("usage.max" => kind_of(Fixnum))
27
+ expect(values).to include("usage.committed" => kind_of(Fixnum))
28
+ expect(values).to include("usage.init" => kind_of(Fixnum))
29
+ expect(values).to include("peak.used" => kind_of(Fixnum))
30
+ expect(values).to include("peak.max" => kind_of(Fixnum))
31
+ expect(values).to include("peak.committed" => kind_of(Fixnum))
32
+ expect(values).to include("peak.init" => kind_of(Fixnum))
33
+ end
34
+ end
35
+ end
36
+
37
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe JRMonitor::Report::Process do
4
+ subject(:process) { described_class.generate }
5
+
6
+ describe "FD Stats" do
7
+ it "should report open FDs" do
8
+ expect(process["open_file_descriptors"]).to be > 0
9
+ end
10
+
11
+ it "should report max FDs possible" do
12
+ expect(process["max_file_descriptors"]).to be > 0
13
+ end
14
+ end
15
+
16
+ describe "mem stats" do
17
+ subject(:mem) { process["mem"] }
18
+
19
+ it "should report the virtual memory in bytes" do
20
+ expect(mem["total_virtual_in_bytes"]).to be > 0
21
+ end
22
+ end
23
+
24
+ describe "CPU stats" do
25
+ subject(:cpu) { process["cpu"] }
26
+
27
+ it "should report the CPU usage for the process" do
28
+ expect(cpu["process_percent"]).to be >= 0
29
+ end
30
+
31
+ it "should report the CPU usage for the process" do
32
+ expect(cpu["system_percent"]).to be >= 0
33
+ end
34
+
35
+ it "should report the total CPU time in millis" do
36
+ expect(cpu["total_in_millis"]).to be > 0
37
+ end
38
+ end
39
+
40
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe JRMonitor::Report::System do
4
+
5
+ let(:report) { subject.generate }
6
+
7
+ it 'pulls system load information' do
8
+ expect(report).to include( "system.load_average" => a_kind_of(Float) )
9
+ end
10
+
11
+ it 'pulls system available processors information' do
12
+ expect(report).to include( "system.available_processors" => a_kind_of(Fixnum) )
13
+ end
14
+
15
+ it 'pulls os version information' do
16
+ expect(report).to include( "os.version" => a_kind_of(String) )
17
+ end
18
+
19
+ it 'pulls os arch information' do
20
+ expect(report).to include( "os.arch" => a_kind_of(String) )
21
+ end
22
+
23
+ it 'pulls os name information' do
24
+ expect(report).to include( "os.name" => a_kind_of(String) )
25
+ end
26
+
27
+ end
@@ -0,0 +1,105 @@
1
+ require 'spec_helper'
2
+
3
+ describe JRMonitor::Report::Threads do
4
+
5
+ let(:threads) { subject.generate }
6
+
7
+ it 'pull running threads' do
8
+ expect(threads.keys.count).to be > 0
9
+ end
10
+
11
+ it 'fetch foreach threads information about cpu time' do
12
+ threads.each_pair do |_, values|
13
+ expect(values).to include('cpu.time')
14
+ end
15
+ end
16
+
17
+ it 'fetch foreach threads information about thread state' do
18
+ threads.each_pair do |_, values|
19
+ expect(values).to include('thread.state')
20
+ end
21
+ end
22
+
23
+ it 'fetch foreach threads information about blocked information' do
24
+ threads.each_pair do |_, values|
25
+ expect(values).to include('blocked.count')
26
+ expect(values).to include('blocked.time')
27
+ end
28
+ end
29
+
30
+ it 'fetch foreach threads information about waited information' do
31
+ threads.each_pair do |_, values|
32
+ expect(values).to include('waited.count')
33
+ expect(values).to include('waited.time')
34
+ end
35
+ end
36
+
37
+ it "fetched the stack traces" do
38
+ threads.each_pair do |key, values|
39
+ next if 'Signal Dispatcher' == key
40
+ expect(values["thread.stacktrace"].count).to be > 0
41
+ end
42
+ end
43
+
44
+ context "with options filtering" do
45
+
46
+ let(:stacktrace_size) { 4 }
47
+ let(:threads) do
48
+ subject.generate(:stacktrace_size => stacktrace_size )
49
+ end
50
+
51
+ it "fetches N stack straces for each thread" do
52
+ threads.each_pair do |key, values|
53
+ next if ['Signal Dispatcher', 'Reference Handler'].include?(key)
54
+ expect(values["thread.stacktrace"].count).to eq(stacktrace_size)
55
+ end
56
+ end
57
+ end
58
+
59
+ describe "#ordering" do
60
+
61
+ let(:ordered_by) { "cpu" }
62
+
63
+ let(:threads) do
64
+ subject.generate(:ordered_by => ordered_by)
65
+ end
66
+
67
+ it 'fetch values ordered by cpu.time' do
68
+ last_cpu_time = 0
69
+ threads.each_pair do |_, values|
70
+ current_cpu_time = values["cpu.time"]
71
+ expect(last_cpu_time).to be >= current_cpu_time if last_cpu_time != 0
72
+ last_cpu_time = current_cpu_time
73
+ end
74
+ end
75
+
76
+ context "with block" do
77
+
78
+ let(:type) { "block" }
79
+
80
+ it 'fetch values ordered by blocked.time' do
81
+ last_time = 0
82
+ threads.each_pair do |_, values|
83
+ current_time = values["blocked.time"]
84
+ expect(last_time).to be >= current_time if last_time != 0
85
+ last_time = current_time
86
+ end
87
+ end
88
+ end
89
+
90
+ context "with wait" do
91
+
92
+ let(:type) { "wait" }
93
+
94
+ it 'fetch values ordered by waited.time' do
95
+ last_time = 0
96
+ threads.each_pair do |_, values|
97
+ current_time = values["waited.time"]
98
+ expect(last_time).to be >= current_time if last_time != 0
99
+ last_time = current_time
100
+ end
101
+ end
102
+ end
103
+
104
+ end
105
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'jrmonitor'
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jrmonitor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.1
5
+ platform: ruby
6
+ authors:
7
+ - Elastic
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-05-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '1.10'
19
+ name: bundler
20
+ prerelease: false
21
+ type: :development
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: 0.10.1
33
+ name: pry
34
+ prerelease: false
35
+ type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.10.1
41
+ - !ruby/object:Gem::Dependency
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '10.0'
47
+ name: rake
48
+ prerelease: false
49
+ type: :development
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ name: rspec
62
+ prerelease: false
63
+ type: :development
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: This gems allows you to access in a Ruby friendly way the internal JVM monitoring tools for things like System, Threads and Memory information
70
+ email:
71
+ - info@elastic.co
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - jrmonitor.gemspec
77
+ - jruby-ext/target/classes/com/purbon/jrmonitor/JRMonitorService$1.class
78
+ - jruby-ext/target/classes/com/purbon/jrmonitor/JRMonitorService$2.class
79
+ - jruby-ext/target/classes/com/purbon/jrmonitor/JRMonitorService$3.class
80
+ - jruby-ext/target/classes/com/purbon/jrmonitor/JRMonitorService$4.class
81
+ - jruby-ext/target/classes/com/purbon/jrmonitor/JRMonitorService.class
82
+ - jruby-ext/target/classes/com/purbon/jrmonitor/JRubyUtils.class
83
+ - jruby-ext/target/classes/com/purbon/jrmonitor/monitors/HotThreadsMonitor$1.class
84
+ - jruby-ext/target/classes/com/purbon/jrmonitor/monitors/HotThreadsMonitor$ThreadReport.class
85
+ - jruby-ext/target/classes/com/purbon/jrmonitor/monitors/HotThreadsMonitor.class
86
+ - jruby-ext/target/classes/com/purbon/jrmonitor/monitors/MemoryMonitor$Report.class
87
+ - jruby-ext/target/classes/com/purbon/jrmonitor/monitors/MemoryMonitor$Type.class
88
+ - jruby-ext/target/classes/com/purbon/jrmonitor/monitors/MemoryMonitor.class
89
+ - jruby-ext/target/classes/com/purbon/jrmonitor/monitors/ProcessMonitor$Report.class
90
+ - jruby-ext/target/classes/com/purbon/jrmonitor/monitors/ProcessMonitor.class
91
+ - jruby-ext/target/classes/com/purbon/jrmonitor/monitors/SystemMonitor$Report.class
92
+ - jruby-ext/target/classes/com/purbon/jrmonitor/monitors/SystemMonitor.class
93
+ - jruby-ext/target/classes/com/purbon/jrmonitor/reports/RubyMemoryReport.class
94
+ - jruby-ext/target/classes/com/purbon/jrmonitor/reports/RubyProcessReport.class
95
+ - jruby-ext/target/classes/com/purbon/jrmonitor/reports/RubySystemReport.class
96
+ - jruby-ext/target/classes/com/purbon/jrmonitor/reports/RubyThreadsReport.class
97
+ - lib/jrmonitor.rb
98
+ - lib/jrmonitor/version.rb
99
+ - spec/lib/memory_monitor_spec.rb
100
+ - spec/lib/process_monitor_spec.rb
101
+ - spec/lib/system_monitor_spec.rb
102
+ - spec/lib/thread_monitor_spec.rb
103
+ - spec/spec_helper.rb
104
+ homepage: http://www.purbon.com
105
+ licenses:
106
+ - Apache License (2.0)
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ - jruby-ext
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.4.8
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: JVM Platform MXBeans wrapper used for monitoring.
129
+ test_files: []