Class: ProcessInfo
- Inherits:
-
Object
- Object
- ProcessInfo
- Defined in:
- app/models/components/linuxprocess.rb
Instance Method Summary collapse
- #get_limits ⇒ Object
-
#initialize(pid) ⇒ ProcessInfo
constructor
A new instance of ProcessInfo.
- #open_files ⇒ Object
- #procpath(path) ⇒ Object
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_limits ⇒ Object
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_files ⇒ Object
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 |