15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/vcap/process_utils.rb', line 15
def get_stats(pid=nil)
pid ||= Process.pid
flags = STAT_FIELDS.map {|f| "-o #{f[:name]}=" }.join(' ')
begin
stdout, stderr, status = VCAP::Subprocess.run("ps #{flags} -p #{pid}")
rescue VCAP::SubprocessStatusError => se
if se.status.exitstatus == 1
return nil
else
raise se
end
end
ret = {}
stdout.split.each_with_index do |val, ii|
field = STAT_FIELDS[ii]
ret[field[:name]] = val.send(field[:parse_method])
end
ret
end
|