eye 0.9.3 → 0.9.4.nosigar

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7fb55aab9464c85b0d2f52d9ecb83f2ef8f6cbc7
4
- data.tar.gz: b36569fbe32ec49ece27216d1fbb340750a6116d
3
+ metadata.gz: df5b3035c5e2270e4314cf21f764d22b5f429221
4
+ data.tar.gz: 3385f97cff38b17f9f93e629b0c7dc94b05ad770
5
5
  SHA512:
6
- metadata.gz: 1de45573f67e9a8b0b8a7a3d93ef19396d0561bcf780d73cb9eee63de3607958c1c634a6edd48556c95460492b407b05ee536cc5489974073f6618354b629cb2
7
- data.tar.gz: 51c5d3ebd48ad1b339a493897a00fe354ee4d9b1c884c53ff198ba253d27a3216c909a248166d6c18591f06460becb0029fedc93db13bd0319953beded5ec94f
6
+ metadata.gz: fae4a420a72fcf37f906fe028313a77d5737b4050038db9e72eb76cc695f62001cc9a7fc6fa7f2631d9b9bb6abcdaca2a72bc6183d26b3451bb4afcbd03f28ca
7
+ data.tar.gz: e330bca5888e30957800455ace776f760154cf0e6388e48e380bb4b87af85a435cb0a00aca068e3740a0d4e71a679c838845fb6a68ea74f5155e99edfe243290
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.9.4
2
+ ----
3
+ * leye used EYE_HOME under root
4
+
1
5
  0.9.3
2
6
  -----
3
7
  * fix process hangs in status :starting, in some rare cases
@@ -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.3'
2
+ VERSION = '0.9.4.nosigar'
3
3
  ABOUT = "Eye v#{VERSION} (c) 2012-2017 @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'
@@ -8,7 +8,6 @@ require_relative 'utils/mini_active_support'
8
8
  Object.send(:include, Eye::Logger::ObjectExt)
9
9
 
10
10
  # needs to preload
11
- Eye::Sigar
12
11
  Eye::SystemResources
13
12
 
14
13
  class Eye::Controller
@@ -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 Sigar].map { |c| gem_version(c) },
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,
@@ -7,4 +7,3 @@ gem 'nio4r'
7
7
  gem 'timers'
8
8
 
9
9
  gem 'state_machines'
10
- gem 'sigar', '~> 0.7.3'
@@ -7,7 +7,11 @@ module Eye::Local
7
7
  def dir
8
8
  @dir ||= begin
9
9
  if root?
10
- '/var/run/eye'
10
+ if (_home = ENV['EYE_HOME']) && !_home.empty?
11
+ File.expand_path(File.join(_home, '.eye'))
12
+ else
13
+ '/var/run/eye'
14
+ end
11
15
  else
12
16
  File.expand_path(File.join(home, '.eye'))
13
17
  end
@@ -4,7 +4,7 @@ module Eye::Process::Config
4
4
  keep_alive: true, # restart when crashed
5
5
  check_alive_period: 5.seconds,
6
6
 
7
- check_identity: true,
7
+ check_identity: false,
8
8
  check_identity_period: 60.seconds,
9
9
  check_identity_grace: 60.seconds,
10
10
 
@@ -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
@@ -7,39 +7,34 @@ class Eye::SystemResources
7
7
 
8
8
  def memory(pid)
9
9
  if mem = cache.proc_mem(pid)
10
- mem.resident
10
+ mem * 1024
11
11
  end
12
12
  end
13
13
 
14
14
  def cpu(pid)
15
- if cpu = cache.proc_cpu(pid)
16
- cpu.percent * 100
17
- end
15
+ cache.proc_cpu(pid)
18
16
  end
19
17
 
20
18
  def children(parent_pid)
21
19
  cache.children(parent_pid)
22
20
  end
23
21
 
24
- # unixtime
25
- def start_time(pid)
26
- if cpu = cache.proc_cpu(pid)
27
- cpu.start_time.to_i / 1000
22
+ def start_time(pid) # unixtime
23
+ if st = cache.proc_start_time(pid)
24
+ Time.parse(st).to_i rescue 0
28
25
  end
29
26
  end
30
27
 
31
28
  # total cpu usage in seconds
32
- def cputime(pid)
33
- if cpu = cache.proc_cpu(pid)
34
- cpu.total.to_f / 1000
35
- end
29
+ def cputime(_pid)
30
+ 0
36
31
  end
37
32
 
38
33
  # last child in a children tree
39
34
  def leaf_child(pid)
40
35
  if dc = deep_children(pid)
41
36
  dc.detect do |child|
42
- args = Eye::Sigar.proc_args(child)[0] rescue ''
37
+ args = ''
43
38
  !args.start_with?('logger') && child != pid
44
39
  end
45
40
  end
@@ -58,8 +53,8 @@ class Eye::SystemResources
58
53
  end
59
54
  end
60
55
 
61
- def args(pid)
62
- Eye::Sigar.proc_args(pid).join(' ').strip rescue '-'
56
+ def args(_pid)
57
+ '-'
63
58
  end
64
59
 
65
60
  def resources(pid)
@@ -93,31 +88,34 @@ class Eye::SystemResources
93
88
  end
94
89
 
95
90
  def clear
96
- @memory = {}
97
- @cpu = {}
98
- @ppids = {}
91
+ @ps_aux = nil
99
92
  end
100
93
 
101
94
  def proc_mem(pid)
102
- @memory[pid] ||= Eye::Sigar.proc_mem(pid) if pid
103
-
104
- rescue ArgumentError
105
- # when incorrect PID, just skip
95
+ ps_aux[pid].try :[], :rss
106
96
  end
107
97
 
108
98
  def proc_cpu(pid)
109
- @cpu[pid] ||= Eye::Sigar.proc_cpu(pid) if pid
99
+ ps_aux[pid].try :[], :cpu
100
+ end
110
101
 
111
- rescue ArgumentError
112
- # when incorrect PID, just skip
102
+ def proc_start_time(pid)
103
+ ps_aux[pid].try :[], :start_time
113
104
  end
114
105
 
115
- def children(pid)
116
- if pid
117
- @ppids[pid] ||= Eye::Sigar.proc_list("State.Ppid.eq=#{pid}")
118
- else
119
- []
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
120
112
  end
113
+
114
+ childs
115
+ end
116
+
117
+ def ps_aux
118
+ @ps_aux ||= defer { Eye::System.ps_aux }
121
119
  end
122
120
 
123
121
  end
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.3
4
+ version: 0.9.4.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: 2017-12-05 00:00:00.000000000 Z
11
+ date: 2018-01-07 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
@@ -1,5 +0,0 @@
1
- require 'sigar'
2
- require 'logger'
3
-
4
- Eye::Sigar = ::Sigar.new
5
- Eye::Sigar.logger = ::Logger.new(nil)