eye 0.9.1 → 0.9.2.nosigar
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +0 -5
- data/eye.gemspec +0 -1
- data/lib/eye.rb +1 -2
- data/lib/eye/application.rb +1 -2
- data/lib/eye/child_process.rb +4 -8
- data/lib/eye/controller.rb +0 -1
- data/lib/eye/controller/status.rb +1 -1
- data/lib/eye/loader.rb +0 -1
- data/lib/eye/logger.rb +1 -2
- data/lib/eye/process/config.rb +1 -1
- data/lib/eye/server.rb +0 -1
- data/lib/eye/system.rb +20 -0
- data/lib/eye/system_resources.rb +27 -28
- data/lib/eye/utils.rb +1 -1
- metadata +2 -17
- data/lib/eye/sigar.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f1f98d5fe3b366203e2e2e969373559e9f17085
|
4
|
+
data.tar.gz: 8b512175c809fac3f0995eff1e03a2875d5b411f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55db19635e608199650d052b64880feec83792ad5f5f6fb4d30fdee5e91e4354adf6237ba773ca15971f0ea5ba920363c4df2a2ce72dba27a5a0a3f378f5dd14
|
7
|
+
data.tar.gz: dab9c2f17dca1e52c6e9070d2c434cff23a01c5f1e8f57104b512c520862c2771835e6172c8d28d1040868c1bc77b9328480b6d58d02871a778ed49948525d44
|
data/Rakefile
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
|
3
3
|
require 'bundler/gem_tasks'
|
4
|
-
require 'rspec/core/rake_task'
|
5
4
|
require 'coveralls/rake/task'
|
6
5
|
|
7
6
|
Coveralls::RakeTask.new
|
@@ -23,10 +22,6 @@ task :split_test do
|
|
23
22
|
abort unless system(cmd)
|
24
23
|
end
|
25
24
|
|
26
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
27
|
-
t.verbose = false
|
28
|
-
end
|
29
|
-
|
30
25
|
task :remove_coverage do
|
31
26
|
require 'fileutils'
|
32
27
|
FileUtils.rm_rf(File.expand_path(File.join(File.dirname(__FILE__), %w{ coverage })))
|
data/eye.gemspec
CHANGED
@@ -23,7 +23,6 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.add_dependency 'celluloid-io', '~> 0.17.0'
|
24
24
|
gem.add_dependency 'state_machines'
|
25
25
|
gem.add_dependency 'thor'
|
26
|
-
gem.add_dependency 'sigar', '~> 0.7.3'
|
27
26
|
|
28
27
|
gem.add_development_dependency 'rake'
|
29
28
|
gem.add_development_dependency 'rspec', '< 2.14'
|
data/lib/eye.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Eye
|
2
|
-
VERSION = '0.9.
|
2
|
+
VERSION = '0.9.2.nosigar'
|
3
3
|
ABOUT = "Eye v#{VERSION} (c) 2012-2016 @kostya"
|
4
4
|
PROCLINE = "eye monitoring v#{VERSION}"
|
5
5
|
|
@@ -19,7 +19,6 @@ module Eye
|
|
19
19
|
autoload :Utils, 'eye/utils'
|
20
20
|
autoload :Notify, 'eye/notify'
|
21
21
|
autoload :Config, 'eye/config'
|
22
|
-
autoload :Sigar, 'eye/sigar'
|
23
22
|
autoload :Controller, 'eye/controller'
|
24
23
|
autoload :Control, 'eye/control'
|
25
24
|
autoload :Cli, 'eye/cli'
|
data/lib/eye/application.rb
CHANGED
data/lib/eye/child_process.rb
CHANGED
@@ -57,8 +57,7 @@ class Eye::ChildProcess
|
|
57
57
|
state == :up
|
58
58
|
end
|
59
59
|
|
60
|
-
def start
|
61
|
-
end
|
60
|
+
def start; end
|
62
61
|
|
63
62
|
def stop
|
64
63
|
kill_process
|
@@ -72,14 +71,11 @@ class Eye::ChildProcess
|
|
72
71
|
end
|
73
72
|
end
|
74
73
|
|
75
|
-
def monitor
|
76
|
-
end
|
74
|
+
def monitor; end
|
77
75
|
|
78
|
-
def unmonitor
|
79
|
-
end
|
76
|
+
def unmonitor; end
|
80
77
|
|
81
|
-
def delete
|
82
|
-
end
|
78
|
+
def delete; end
|
83
79
|
|
84
80
|
def destroy
|
85
81
|
remove_watchers
|
data/lib/eye/controller.rb
CHANGED
@@ -9,7 +9,7 @@ module Eye::Controller::Status
|
|
9
9
|
about: Eye::ABOUT,
|
10
10
|
resources: Eye::SystemResources.resources($$),
|
11
11
|
ruby: RUBY_DESCRIPTION,
|
12
|
-
gems: %w[Celluloid Celluloid::IO StateMachines NIO Timers
|
12
|
+
gems: %w[Celluloid Celluloid::IO StateMachines NIO Timers].map { |c| gem_version(c) },
|
13
13
|
logger: Eye::Logger.args.present? ? [Eye::Logger.dev.to_s, *Eye::Logger.args] : Eye::Logger.dev.to_s,
|
14
14
|
home: Eye::Local.home,
|
15
15
|
dir: Eye::Local.dir,
|
data/lib/eye/loader.rb
CHANGED
data/lib/eye/logger.rb
CHANGED
data/lib/eye/process/config.rb
CHANGED
data/lib/eye/server.rb
CHANGED
@@ -36,7 +36,6 @@ class Eye::Server
|
|
36
36
|
begin
|
37
37
|
sign, msg_size = text[0...8].unpack('N*')
|
38
38
|
raise "unknown protocol #{sign}" unless sign == Eye::Client::SIGN
|
39
|
-
msg_size = text[4...8].unpack('N')[0]
|
40
39
|
content = text[8..-1]
|
41
40
|
content << socket.read(msg_size - content.length) while content.length < msg_size
|
42
41
|
payload = Marshal.load(content)
|
data/lib/eye/system.rb
CHANGED
@@ -140,6 +140,26 @@ module Eye::System
|
|
140
140
|
env
|
141
141
|
end
|
142
142
|
|
143
|
+
PS_AUX_CMD = if RUBY_PLATFORM.include?('darwin')
|
144
|
+
'ps axo pid,ppid,pcpu,rss,start'
|
145
|
+
else
|
146
|
+
'ps axo pid,ppid,pcpu,rss,start_time'
|
147
|
+
end
|
148
|
+
|
149
|
+
# get table
|
150
|
+
# {pid => {:rss =>, :cpu =>, :ppid => , :start_time => }}
|
151
|
+
# slow
|
152
|
+
def ps_aux
|
153
|
+
str = Process.send('`', PS_AUX_CMD).force_encoding('binary')
|
154
|
+
h = {}
|
155
|
+
str.each_line do |line|
|
156
|
+
chunk = line.strip.split(%r[\s+])
|
157
|
+
h[chunk[0].to_i] = { ppid: chunk[1].to_i, cpu: chunk[2].to_i,
|
158
|
+
rss: chunk[3].to_i, start_time: chunk[4] }
|
159
|
+
end
|
160
|
+
h
|
161
|
+
end
|
162
|
+
|
143
163
|
end
|
144
164
|
|
145
165
|
end
|
data/lib/eye/system_resources.rb
CHANGED
@@ -7,14 +7,12 @@ class Eye::SystemResources
|
|
7
7
|
|
8
8
|
def memory(pid)
|
9
9
|
if mem = cache.proc_mem(pid)
|
10
|
-
mem
|
10
|
+
mem * 1024
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def cpu(pid)
|
15
|
-
|
16
|
-
cpu.percent * 100
|
17
|
-
end
|
15
|
+
cache.proc_cpu(pid)
|
18
16
|
end
|
19
17
|
|
20
18
|
def children(parent_pid)
|
@@ -22,23 +20,21 @@ class Eye::SystemResources
|
|
22
20
|
end
|
23
21
|
|
24
22
|
def start_time(pid) # unixtime
|
25
|
-
if
|
26
|
-
|
23
|
+
if st = cache.proc_start_time(pid)
|
24
|
+
Time.parse(st).to_i
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
30
28
|
# total cpu usage in seconds
|
31
|
-
def cputime(
|
32
|
-
|
33
|
-
cpu.total.to_f / 1000
|
34
|
-
end
|
29
|
+
def cputime(_pid)
|
30
|
+
0
|
35
31
|
end
|
36
32
|
|
37
33
|
# last child in a children tree
|
38
34
|
def leaf_child(pid)
|
39
35
|
if dc = deep_children(pid)
|
40
36
|
dc.detect do |child|
|
41
|
-
args =
|
37
|
+
args = ''
|
42
38
|
!args.start_with?('logger') && child != pid
|
43
39
|
end
|
44
40
|
end
|
@@ -57,8 +53,8 @@ class Eye::SystemResources
|
|
57
53
|
end
|
58
54
|
end
|
59
55
|
|
60
|
-
def args(
|
61
|
-
|
56
|
+
def args(_pid)
|
57
|
+
'-'
|
62
58
|
end
|
63
59
|
|
64
60
|
def resources(pid)
|
@@ -92,31 +88,34 @@ class Eye::SystemResources
|
|
92
88
|
end
|
93
89
|
|
94
90
|
def clear
|
95
|
-
@
|
96
|
-
@cpu = {}
|
97
|
-
@ppids = {}
|
91
|
+
@ps_aux = nil
|
98
92
|
end
|
99
93
|
|
100
94
|
def proc_mem(pid)
|
101
|
-
|
102
|
-
|
103
|
-
rescue ArgumentError
|
104
|
-
# when incorrect PID, just skip
|
95
|
+
ps_aux[pid].try :[], :rss
|
105
96
|
end
|
106
97
|
|
107
98
|
def proc_cpu(pid)
|
108
|
-
|
99
|
+
ps_aux[pid].try :[], :cpu
|
100
|
+
end
|
109
101
|
|
110
|
-
|
111
|
-
|
102
|
+
def proc_start_time(pid)
|
103
|
+
ps_aux[pid].try :[], :start_time
|
112
104
|
end
|
113
105
|
|
114
|
-
def children(
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
106
|
+
def children(parent_pid)
|
107
|
+
parent_pid = parent_pid.to_i
|
108
|
+
|
109
|
+
childs = []
|
110
|
+
ps_aux.each do |pid, h|
|
111
|
+
childs << pid if h[:ppid] == parent_pid
|
119
112
|
end
|
113
|
+
|
114
|
+
childs
|
115
|
+
end
|
116
|
+
|
117
|
+
def ps_aux
|
118
|
+
@ps_aux ||= defer { Eye::System.ps_aux }
|
120
119
|
end
|
121
120
|
|
122
121
|
end
|
data/lib/eye/utils.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eye
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2.nosigar
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Makarchev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: sigar
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 0.7.3
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 0.7.3
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: rake
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -434,7 +420,6 @@ files:
|
|
434
420
|
- lib/eye/process/validate.rb
|
435
421
|
- lib/eye/process/watchers.rb
|
436
422
|
- lib/eye/server.rb
|
437
|
-
- lib/eye/sigar.rb
|
438
423
|
- lib/eye/system.rb
|
439
424
|
- lib/eye/system_resources.rb
|
440
425
|
- lib/eye/trigger.rb
|