cellumon 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +5 -0
- data/README.md +3 -0
- data/Rakefile +1 -0
- data/cellumon.gemspec +20 -0
- data/lib/cellumon.rb +113 -0
- metadata +50 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d8c771c909a0dcfadcaaf03a9f3365512ed905b2
|
4
|
+
data.tar.gz: 560365358c89e138292cd0722ec7c9264ab262cf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c9c19bdaf3a6e418f0c7b8d8e62d7786639a98cd80ba4a41d1b2e9b7d27a3d29d709afd477de54a5a6a510021ba356135453f580f848a09a7b91c86de52702a8
|
7
|
+
data.tar.gz: 146126ea2a81af3c29523e5d85a3cb8de1ae15b11fb7f9af35bfe8809a47860bf9181a3dac107ff6a19a448ec4dae514721d9461076374b0aec4a3ad06262f7d
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/cellumon.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = "cellumon"
|
5
|
+
gem.version = "0.1.0"
|
6
|
+
gem.platform = Gem::Platform::RUBY
|
7
|
+
gem.summary = "Monitor threads, processes, and states of Celluloid and its Actor System."
|
8
|
+
gem.description = "Thread summary and reporting actor, utility for finding leaks and monitoring."
|
9
|
+
gem.licenses = ["MIT"]
|
10
|
+
|
11
|
+
gem.authors = ["digitalextremist //"]
|
12
|
+
gem.email = ["code@extremist.digital"]
|
13
|
+
gem.homepage = "https://github.com/digitalextremist/cellumon"
|
14
|
+
|
15
|
+
gem.required_ruby_version = ">= 1.9.2"
|
16
|
+
gem.required_rubygems_version = ">= 1.3.6"
|
17
|
+
|
18
|
+
gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|examples|spec|features)/}) }
|
19
|
+
gem.require_path = "lib"
|
20
|
+
end
|
data/lib/cellumon.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'celluloid/current'
|
3
|
+
|
4
|
+
class Cellumon
|
5
|
+
|
6
|
+
include Celluloid
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def start!(name=:cellumon)
|
10
|
+
Cellumon.supervise(as: name)
|
11
|
+
Celluloid[:cellumon]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
MONITORS = {
|
16
|
+
thread_survey: 30,
|
17
|
+
thread_report: 15,
|
18
|
+
thread_summary: 1,
|
19
|
+
memory_count: 13
|
20
|
+
}
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@semaphor = {}
|
24
|
+
@status = {}
|
25
|
+
@timers = {}
|
26
|
+
@intervals = MONITORS.dup
|
27
|
+
end
|
28
|
+
|
29
|
+
MONITORS.each { |m,i|
|
30
|
+
define_method(:"start_#{m}!") { |interval=nil|
|
31
|
+
async.send1(:"starting_#{m}")
|
32
|
+
}
|
33
|
+
define_method(:"starting_#{m}") { |interval=nil|
|
34
|
+
@intervals[m] = interval || MONITORS[m]
|
35
|
+
@timers[m] = nil
|
36
|
+
@semaphor[m] = Mutex.new
|
37
|
+
@status[m] = :initializing
|
38
|
+
async.send :"#{m}!"
|
39
|
+
ready! m
|
40
|
+
}
|
41
|
+
define_method(:"stop_#{m}!") {
|
42
|
+
stopped! m
|
43
|
+
@timers[m].cancel if @timers[m]
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
def memory_count!
|
48
|
+
if ready? :memory_count
|
49
|
+
console("Memory usage: #{`pmap #{Process.pid} | tail -1`[10,40].strip}")
|
50
|
+
ready! :memory_count
|
51
|
+
end
|
52
|
+
@timers[:memory_count] = after(@intervals[:memory_count]) { memory_count! }
|
53
|
+
end
|
54
|
+
|
55
|
+
def thread_survey!
|
56
|
+
if ready? :thread_survey
|
57
|
+
Celluloid.stack_summary
|
58
|
+
ready! :thread_survey
|
59
|
+
end
|
60
|
+
@timers[:thread_survey] = after(@intervals[:thread_survey]) { thread_survey! }
|
61
|
+
end
|
62
|
+
|
63
|
+
def thread_summary!
|
64
|
+
if ready? :thread_summary
|
65
|
+
print " #{Thread.list.count} "
|
66
|
+
ready! :thread_summary
|
67
|
+
end
|
68
|
+
@timers[:thread_summary] = after(@intervals[:thread_summary]) { thread_summary! }
|
69
|
+
end
|
70
|
+
|
71
|
+
def thread_report!
|
72
|
+
if ready? :thread_report
|
73
|
+
threads = Thread.list.inject({}) { |l,t| l[t.object_id] = t.status; l }
|
74
|
+
running = threads.select { |id,status| status == 'run' }.count
|
75
|
+
sleeping = threads.select { |id,status| status == 'sleep' }.count
|
76
|
+
aborting = threads.select { |id,status| status == 'aborting' }.count
|
77
|
+
normally_terminated = threads.select { |id,status| status === false }.count
|
78
|
+
exception_terminated = threads.select { |id,status| status.nil? }.count
|
79
|
+
console "Threads #{threads.count}; " +
|
80
|
+
"Running (#{running}) Sleeping (#{sleeping}) Aborting (#{aborting}); " +
|
81
|
+
"Terminated: Normally (#{normally_terminated}) Exception (#{exception_terminated})"
|
82
|
+
ready! :thread_report
|
83
|
+
end
|
84
|
+
@timers[:thread_report] = after(@intervals[:thread_report]) { thread_report! }
|
85
|
+
end
|
86
|
+
|
87
|
+
def console(message)
|
88
|
+
puts "*, [#{Time.now.strftime('%FT%T.%L')}] Cellumon > #{message}"
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def ready! monitor
|
94
|
+
@semaphor[monitor].synchronize { @status[monitor] = :ready }
|
95
|
+
end
|
96
|
+
|
97
|
+
def running! monitor
|
98
|
+
@semaphor[monitor].synchronize { @status[monitor] = :running }
|
99
|
+
end
|
100
|
+
|
101
|
+
def stopped! monitor
|
102
|
+
@semaphor[monitor].synchronize { @status[monitor] = :stopped }
|
103
|
+
end
|
104
|
+
|
105
|
+
def ready? monitor
|
106
|
+
@semaphor[monitor].synchronize { @status[monitor] == :ready }
|
107
|
+
end
|
108
|
+
|
109
|
+
def output object
|
110
|
+
puts JSON.pretty_generate(object)
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
metadata
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cellumon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- digitalextremist //
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-07 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Thread summary and reporting actor, utility for finding leaks and monitoring.
|
14
|
+
email:
|
15
|
+
- code@extremist.digital
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- .gitignore
|
21
|
+
- Gemfile
|
22
|
+
- README.md
|
23
|
+
- Rakefile
|
24
|
+
- cellumon.gemspec
|
25
|
+
- lib/cellumon.rb
|
26
|
+
homepage: https://github.com/digitalextremist/cellumon
|
27
|
+
licenses:
|
28
|
+
- MIT
|
29
|
+
metadata: {}
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 1.9.2
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.3.6
|
44
|
+
requirements: []
|
45
|
+
rubyforge_project:
|
46
|
+
rubygems_version: 2.4.8
|
47
|
+
signing_key:
|
48
|
+
specification_version: 4
|
49
|
+
summary: Monitor threads, processes, and states of Celluloid and its Actor System.
|
50
|
+
test_files: []
|