Class: ProcessInfo

Inherits:
Object
  • Object
show all
Defined in:
app/models/components/linuxprocess.rb

Instance Method Summary collapse

Constructor Details

#initialize(pid) ⇒ ProcessInfo

Returns a new instance of ProcessInfo.



32
33
34
# File 'app/models/components/linuxprocess.rb', line 32

def initialize(pid)
  @pid = pid
end

Instance Method Details

#get_limitsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/models/components/linuxprocess.rb', line 40

def get_limits
  linere = /^Max (.*?) +\S+ +(\S+)(?: +\S+\s*)?$/
  limits = Hash.new
  File.open(procpath("limits")).each do |line|
    line.chomp!
    next if line =~ /^Limit/
    puts line
    match = linere.match(line)
    next if match == nil
    limits[match.captures[0]] = match.captures[1]
  end
  return limits
end

#open_filesObject



54
55
56
# File 'app/models/components/linuxprocess.rb', line 54

def open_files
  return Dir.glob(procpath("fd/*")).length
end

#procpath(path) ⇒ Object



36
37
38
# File 'app/models/components/linuxprocess.rb', line 36

def procpath(path)
  return "/proc/#{@pid}/#{path}"
end