Class: VCAP::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/vcap/stats.rb

Class Method Summary collapse

Class Method Details

.cpu_load_averageObject



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_bytesObject



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_bytesObject



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_cpuObject



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