Class: VCAP::Stats
- Inherits:
-
Object
- Object
- VCAP::Stats
- Defined in:
- lib/vcap/stats.rb
Class Method Summary collapse
- .cpu_load_average ⇒ Object
- .memory_free_bytes ⇒ Object
- .memory_used_bytes ⇒ Object
- .process_memory_bytes_and_cpu ⇒ Object
Class Method Details
.cpu_load_average ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/vcap/stats.rb', line 38 def cpu_load_average if WINDOWS windows_cpu_load else Vmstat.load_average.one_minute end end |
.memory_free_bytes ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/vcap/stats.rb', line 28 def memory_free_bytes if WINDOWS mem = windows_memory_used mem[:available] else mem = Vmstat.memory mem.inactive_bytes + mem.free_bytes end end |
.memory_used_bytes ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/vcap/stats.rb', line 18 def memory_used_bytes if WINDOWS mem = windows_memory_used mem[:total] - mem[:available] else mem = Vmstat.memory mem.active_bytes + mem.wired_bytes end end |
.process_memory_bytes_and_cpu ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/vcap/stats.rb', line 7 def process_memory_bytes_and_cpu if WINDOWS rss_bytes = windows_process_memory * 1024 pcpu = windows_process_cpu else rss, pcpu = `ps -o rss=,pcpu= -p #{Process.pid}`.split.map(&:to_i) rss_bytes = rss * 1024 end [rss_bytes, pcpu] end |