Class: Eye::SystemResources
- Inherits:
-
Object
- Object
- Eye::SystemResources
- Defined in:
- lib/eye/system_resources.rb
Defined Under Namespace
Classes: PsAxActor
Class Method Summary collapse
- .childs(parent_pid) ⇒ Object
- .cpu(pid) ⇒ Object
- .memory(pid) ⇒ Object
- .resources(pid) ⇒ Object
-
.setup ⇒ Object
initialize actor, call 1 time before using.
- .start_time(pid) ⇒ Object
Class Method Details
.childs(parent_pid) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/eye/system_resources.rb', line 16 def childs(parent_pid) parent_pid = parent_pid.to_i childs = [] ps_aux.each do |pid, h| childs << pid if h[:ppid] == parent_pid end childs end |
.cpu(pid) ⇒ Object
12 13 14 |
# File 'lib/eye/system_resources.rb', line 12 def cpu(pid) ps_aux[pid].try :[], :cpu end |
.memory(pid) ⇒ Object
8 9 10 |
# File 'lib/eye/system_resources.rb', line 8 def memory(pid) ps_aux[pid].try :[], :rss end |
.resources(pid) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/eye/system_resources.rb', line 31 def resources(pid) return {} unless ps_aux[pid] { :memory => memory(pid), :cpu => cpu(pid), :start_time => start_time(pid), :pid => pid } end |
.setup ⇒ Object
initialize actor, call 1 time before using
42 43 44 |
# File 'lib/eye/system_resources.rb', line 42 def setup @actor ||= PsAxActor.new end |
.start_time(pid) ⇒ Object
27 28 29 |
# File 'lib/eye/system_resources.rb', line 27 def start_time(pid) ps_aux[pid].try :[], :start_time end |