Class: Eye::SystemResources::Cache
- Includes:
- Celluloid
- Defined in:
- lib/eye/system_resources.rb
Instance Attribute Summary collapse
-
#expire ⇒ Object
readonly
Returns the value of attribute expire.
Instance Method Summary collapse
- #children(pid) ⇒ Object
- #clear ⇒ Object
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
- #proc_cpu(pid) ⇒ Object
- #proc_mem(pid) ⇒ Object
- #setup_expire(expire = 5) ⇒ Object
Constructor Details
#initialize ⇒ Cache
Returns a new instance of Cache.
78 79 80 81 |
# File 'lib/eye/system_resources.rb', line 78 def initialize clear setup_expire end |
Instance Attribute Details
#expire ⇒ Object (readonly)
Returns the value of attribute expire.
76 77 78 |
# File 'lib/eye/system_resources.rb', line 76 def expire @expire end |
Instance Method Details
#children(pid) ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/eye/system_resources.rb', line 107 def children(pid) if pid @ppids[pid] ||= Eye::Sigar.proc_list("State.Ppid.eq=#{pid}") else [] end end |
#clear ⇒ Object
89 90 91 92 93 |
# File 'lib/eye/system_resources.rb', line 89 def clear @memory = {} @cpu = {} @ppids = {} end |
#proc_cpu(pid) ⇒ Object
101 102 103 104 105 |
# File 'lib/eye/system_resources.rb', line 101 def proc_cpu(pid) @cpu[pid] ||= Eye::Sigar.proc_cpu(pid) if pid rescue ArgumentError # when incorrect PID end |
#proc_mem(pid) ⇒ Object
95 96 97 98 99 |
# File 'lib/eye/system_resources.rb', line 95 def proc_mem(pid) @memory[pid] ||= Eye::Sigar.proc_mem(pid) if pid rescue ArgumentError # when incorrect PID end |
#setup_expire(expire = 5) ⇒ Object
83 84 85 86 87 |
# File 'lib/eye/system_resources.rb', line 83 def setup_expire(expire = 5) @expire = expire @timer.cancel if @timer @timer = every(@expire) { clear } end |