esto 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +20 -0
- data/README.md +3 -0
- data/Rakefile +1 -0
- data/esto.gemspec +23 -0
- data/lib/abstractive/esto.rb +142 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9300ca3a75b7ae9aceae68809e583f8b628bf844
|
4
|
+
data.tar.gz: de7db3190a7634b42ce0f99f5c2658bd589e380b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b9f297046ee0d85fb8ef6b720e8bd697d025d94cb03b63de5fa20435934cfa709716257ae3d4e308d0a1d03b88caf99a2ecfbb2681c9283fdc9c3725ec59c351
|
7
|
+
data.tar.gz: 398a6be7ad65e6dece999104c7513f9c54e5dcef5c09958daed45f62e99c19fc6f7e0a60475b5d6451486ae7bda699a83192b7e8184ecefff854431d70205d99
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2015 digitalextremist //
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/esto.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = "esto"
|
5
|
+
gem.version = "0.7.0"
|
6
|
+
gem.platform = Gem::Platform::RUBY
|
7
|
+
gem.summary = "Monitor processes; uptime, threads and memory, and actor system states."
|
8
|
+
gem.description = "Process statistics, and utility for finding problems in Celluloid systems."
|
9
|
+
gem.licenses = ["MIT"]
|
10
|
+
|
11
|
+
gem.authors = ["digitalextremist //"]
|
12
|
+
gem.email = ["code@extremist.digital"]
|
13
|
+
gem.homepage = "https://github.com/abstractive/esto"
|
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
|
+
gem.add_runtime_dependency "celluloid", ">= 0.17.0"
|
21
|
+
gem.add_runtime_dependency "abstractive"
|
22
|
+
gem.add_runtime_dependency "timespans"
|
23
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'abstractive'
|
3
|
+
require 'abstractive/timespans'
|
4
|
+
require 'abstractive/actor'
|
5
|
+
|
6
|
+
class Abstractive::Esto < Abstractive::Actor
|
7
|
+
|
8
|
+
extend Forwardable
|
9
|
+
def_delegators :"Abstractive::TimeSpans", :duration, :readable_duration
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def start!(options={})
|
13
|
+
name = options.delete(:name) || :proceso
|
14
|
+
Abstractive::Esto.supervise(as: name, args: [options])
|
15
|
+
Celluloid[name]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
MONITORS = {
|
20
|
+
uptime: 90,
|
21
|
+
thread_survey: 30,
|
22
|
+
thread_report: 15,
|
23
|
+
thread_summary: 3,
|
24
|
+
memory_count: 13,
|
25
|
+
threads_and_memory: 45
|
26
|
+
}
|
27
|
+
|
28
|
+
def initialize(options={})
|
29
|
+
@semaphor = {}
|
30
|
+
@status = {}
|
31
|
+
@timers = {}
|
32
|
+
@debug = options.fetch(:debug, false)
|
33
|
+
@logger = options.fetch(:logger, nil)
|
34
|
+
@declare = options.fetch(:declare, false)
|
35
|
+
@intervals = MONITORS.dup
|
36
|
+
@options = options
|
37
|
+
@running = Hitimes::Interval.now
|
38
|
+
async.start
|
39
|
+
end
|
40
|
+
|
41
|
+
def start
|
42
|
+
if @options[:monitors].is_a?(Array)
|
43
|
+
debug("Monitors:") if @debug
|
44
|
+
@options[:monitors].each { |monitor|
|
45
|
+
debug("* #{monitor} every #{readable_duration(MONITORS[monitor])}.") if @debug
|
46
|
+
send("start_#{monitor}!")
|
47
|
+
}
|
48
|
+
else
|
49
|
+
debug("No preconfigured monitors.") if @debug
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
MONITORS.each { |m,i|
|
54
|
+
define_method(:"start_#{m}!") { |interval=nil|
|
55
|
+
async.send(:"starting_#{m}")
|
56
|
+
}
|
57
|
+
define_method(:"starting_#{m}") { |interval=nil|
|
58
|
+
@intervals[m] = interval || MONITORS[m]
|
59
|
+
@timers[m] = nil
|
60
|
+
@semaphor[m] = Mutex.new
|
61
|
+
@status[m] = :initializing
|
62
|
+
async.send :"#{m}!"
|
63
|
+
ready! m
|
64
|
+
}
|
65
|
+
define_method(:"stop_#{m}!") {
|
66
|
+
stopped! m
|
67
|
+
@timers[m].cancel if @timers[m]
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
def uptime!
|
72
|
+
trigger!(:uptime) { console "Uptime: #{readable_duration(@running.duration_so_far)}" }
|
73
|
+
end
|
74
|
+
|
75
|
+
def memory_count!
|
76
|
+
trigger!(:memory_count) { console memory }
|
77
|
+
end
|
78
|
+
|
79
|
+
def thread_survey!
|
80
|
+
trigger!(:thread_survey) { Celluloid.stack_summary }
|
81
|
+
end
|
82
|
+
|
83
|
+
def thread_summary!
|
84
|
+
trigger!(:thread_summary) { print " #{Thread.list.count} " }
|
85
|
+
end
|
86
|
+
|
87
|
+
def thread_report!
|
88
|
+
trigger!(:thread_report) { console threads }
|
89
|
+
end
|
90
|
+
|
91
|
+
def threads_and_memory!
|
92
|
+
trigger!(:threads_and_memory) { console "#{threads}; #{memory}" }
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def threads
|
98
|
+
threads = Thread.list.inject({}) { |l,t| l[t.object_id] = t.status; l }
|
99
|
+
r = threads.select { |id,status| status == 'run' }.count
|
100
|
+
s = threads.select { |id,status| status == 'sleep' }.count
|
101
|
+
a = threads.select { |id,status| status == 'aborting' }.count
|
102
|
+
nt = threads.select { |id,status| status === false }.count
|
103
|
+
te = threads.select { |id,status| status.nil? }.count
|
104
|
+
"Threads #{threads.count}: #{r}r #{s}s #{a}a #{nt}nt #{te}te"
|
105
|
+
end
|
106
|
+
|
107
|
+
def memory
|
108
|
+
total = `pmap #{Process.pid} | tail -1`[10,40].strip[0..-1].to_i
|
109
|
+
gb = (total / (1024 * 1024)).to_i
|
110
|
+
mb = total % gb
|
111
|
+
"Memory: #{'%0.2f' % "#{gb}.#{mb}"}gb" #de Very fuzzy math but fine for now.
|
112
|
+
end
|
113
|
+
|
114
|
+
def trigger!(monitor)
|
115
|
+
puts "trigger: #{monitor}" if @debug
|
116
|
+
if ready?(monitor)
|
117
|
+
result = yield
|
118
|
+
ready! monitor
|
119
|
+
end
|
120
|
+
@timers[monitor].cancel rescue nil
|
121
|
+
@timers[monitor] = after(@intervals[monitor]) { send("#{monitor}!") }
|
122
|
+
result
|
123
|
+
rescue => ex
|
124
|
+
exception(ex, "Abstractive::Esto > Failure to trigger: #{monitor}")
|
125
|
+
end
|
126
|
+
|
127
|
+
[:debug,:console].each { |m|
|
128
|
+
define_method(m) {|message, options={}|
|
129
|
+
super(message, options.merge(reporter: "Abstractive::Esto", declare: @declare))
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
[:ready, :running, :stopped].each { |state|
|
134
|
+
define_method("#{state}!") { |monitor|
|
135
|
+
@semaphor[monitor].synchronize { @status[monitor] = state }
|
136
|
+
}
|
137
|
+
define_method("#{state}?") { |monitor|
|
138
|
+
@semaphor[monitor].synchronize { @status[monitor] == state }
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: esto
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- digitalextremist //
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-01 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: 0.17.0
|
19
|
+
name: celluloid
|
20
|
+
prerelease: false
|
21
|
+
type: :runtime
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.17.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
name: abstractive
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
name: timespans
|
48
|
+
prerelease: false
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Process statistics, and utility for finding problems in Celluloid systems.
|
56
|
+
email:
|
57
|
+
- code@extremist.digital
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- esto.gemspec
|
68
|
+
- lib/abstractive/esto.rb
|
69
|
+
homepage: https://github.com/abstractive/esto
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 1.9.2
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 1.3.6
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.4.8
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Monitor processes; uptime, threads and memory, and actor system states.
|
93
|
+
test_files: []
|