eye 0.9.2.nosigar → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/eye.gemspec +1 -0
- data/lib/eye.rb +2 -1
- data/lib/eye/controller.rb +1 -0
- data/lib/eye/controller/status.rb +1 -1
- data/lib/eye/loader.rb +1 -0
- data/lib/eye/process/config.rb +1 -1
- data/lib/eye/sigar.rb +5 -0
- data/lib/eye/system.rb +0 -20
- data/lib/eye/system_resources.rb +28 -27
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc90dbe500dcdec39abb07eed2c8a9391cb8e619
|
4
|
+
data.tar.gz: b0c7fe91dad6d81afa03467fa4af801e9a8cd619
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3211c83195c0fccacbe73705a2f822079f2cdeecfa1ab5b1aa43587574ed2fe7369a60b2ca2a5365a4fdaba97f3d1330bbd4c280e607f35140d84ea954984b81
|
7
|
+
data.tar.gz: 5e7cab54e3f1ceae0d3edf0f54e73976b24c61258f1e770508a1be20ae7b87c12acd9edef70212bf2e85c6f7efbaa1c617e1aeb627ec07db40b28b688981ad37
|
data/eye.gemspec
CHANGED
@@ -23,6 +23,7 @@ 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'
|
26
27
|
|
27
28
|
gem.add_development_dependency 'rake'
|
28
29
|
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
|
2
|
+
VERSION = '0.9.2'
|
3
3
|
ABOUT = "Eye v#{VERSION} (c) 2012-2016 @kostya"
|
4
4
|
PROCLINE = "eye monitoring v#{VERSION}"
|
5
5
|
|
@@ -19,6 +19,7 @@ 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'
|
22
23
|
autoload :Controller, 'eye/controller'
|
23
24
|
autoload :Control, 'eye/control'
|
24
25
|
autoload :Cli, 'eye/cli'
|
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].map { |c| gem_version(c) },
|
12
|
+
gems: %w[Celluloid Celluloid::IO StateMachines NIO Timers Sigar].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/process/config.rb
CHANGED
data/lib/eye/sigar.rb
ADDED
data/lib/eye/system.rb
CHANGED
@@ -140,26 +140,6 @@ 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
|
-
|
163
143
|
end
|
164
144
|
|
165
145
|
end
|
data/lib/eye/system_resources.rb
CHANGED
@@ -7,12 +7,14 @@ class Eye::SystemResources
|
|
7
7
|
|
8
8
|
def memory(pid)
|
9
9
|
if mem = cache.proc_mem(pid)
|
10
|
-
mem
|
10
|
+
mem.resident
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def cpu(pid)
|
15
|
-
cache.proc_cpu(pid)
|
15
|
+
if cpu = cache.proc_cpu(pid)
|
16
|
+
cpu.percent * 100
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
20
|
def children(parent_pid)
|
@@ -20,21 +22,23 @@ class Eye::SystemResources
|
|
20
22
|
end
|
21
23
|
|
22
24
|
def start_time(pid) # unixtime
|
23
|
-
if
|
24
|
-
|
25
|
+
if cpu = cache.proc_cpu(pid)
|
26
|
+
cpu.start_time.to_i / 1000
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
30
|
# total cpu usage in seconds
|
29
|
-
def cputime(
|
30
|
-
|
31
|
+
def cputime(pid)
|
32
|
+
if cpu = cache.proc_cpu(pid)
|
33
|
+
cpu.total.to_f / 1000
|
34
|
+
end
|
31
35
|
end
|
32
36
|
|
33
37
|
# last child in a children tree
|
34
38
|
def leaf_child(pid)
|
35
39
|
if dc = deep_children(pid)
|
36
40
|
dc.detect do |child|
|
37
|
-
args = ''
|
41
|
+
args = Eye::Sigar.proc_args(child)[0] rescue ''
|
38
42
|
!args.start_with?('logger') && child != pid
|
39
43
|
end
|
40
44
|
end
|
@@ -53,8 +57,8 @@ class Eye::SystemResources
|
|
53
57
|
end
|
54
58
|
end
|
55
59
|
|
56
|
-
def args(
|
57
|
-
'-'
|
60
|
+
def args(pid)
|
61
|
+
Eye::Sigar.proc_args(pid).join(' ').strip rescue '-'
|
58
62
|
end
|
59
63
|
|
60
64
|
def resources(pid)
|
@@ -88,34 +92,31 @@ class Eye::SystemResources
|
|
88
92
|
end
|
89
93
|
|
90
94
|
def clear
|
91
|
-
@
|
95
|
+
@memory = {}
|
96
|
+
@cpu = {}
|
97
|
+
@ppids = {}
|
92
98
|
end
|
93
99
|
|
94
100
|
def proc_mem(pid)
|
95
|
-
|
101
|
+
@memory[pid] ||= Eye::Sigar.proc_mem(pid) if pid
|
102
|
+
|
103
|
+
rescue ArgumentError
|
104
|
+
# when incorrect PID, just skip
|
96
105
|
end
|
97
106
|
|
98
107
|
def proc_cpu(pid)
|
99
|
-
|
100
|
-
end
|
108
|
+
@cpu[pid] ||= Eye::Sigar.proc_cpu(pid) if pid
|
101
109
|
|
102
|
-
|
103
|
-
|
110
|
+
rescue ArgumentError
|
111
|
+
# when incorrect PID, just skip
|
104
112
|
end
|
105
113
|
|
106
|
-
def children(
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
childs << pid if h[:ppid] == parent_pid
|
114
|
+
def children(pid)
|
115
|
+
if pid
|
116
|
+
@ppids[pid] ||= Eye::Sigar.proc_list("State.Ppid.eq=#{pid}")
|
117
|
+
else
|
118
|
+
[]
|
112
119
|
end
|
113
|
-
|
114
|
-
childs
|
115
|
-
end
|
116
|
-
|
117
|
-
def ps_aux
|
118
|
-
@ps_aux ||= defer { Eye::System.ps_aux }
|
119
120
|
end
|
120
121
|
|
121
122
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eye
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.2
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Makarchev
|
@@ -66,6 +66,20 @@ 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
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -420,6 +434,7 @@ files:
|
|
420
434
|
- lib/eye/process/validate.rb
|
421
435
|
- lib/eye/process/watchers.rb
|
422
436
|
- lib/eye/server.rb
|
437
|
+
- lib/eye/sigar.rb
|
423
438
|
- lib/eye/system.rb
|
424
439
|
- lib/eye/system_resources.rb
|
425
440
|
- lib/eye/trigger.rb
|