Class: Cloudscopes::Process::SystemProcess
- Inherits:
-
Object
- Object
- Cloudscopes::Process::SystemProcess
- Defined in:
- lib/cloudscopes/process.rb
Instance Method Summary collapse
- #exe ⇒ Object
- #exe_name ⇒ Object
-
#initialize(id) ⇒ SystemProcess
constructor
A new instance of SystemProcess.
- #procpath(field = nil) ⇒ Object
- #uid ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(id) ⇒ SystemProcess
Returns a new instance of SystemProcess.
8 9 10 11 |
# File 'lib/cloudscopes/process.rb', line 8 def initialize(id) @id = id.to_i raise "Invalid system process id #{id}" unless @id > 0 && @id <= 65536 end |
Instance Method Details
#exe ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/cloudscopes/process.rb', line 17 def exe begin File.readlink(procpath('exe')) rescue SystemCallError => e # report and ignore $stderr.puts "Error accessing process #{@id}: #{e.message}" '' end end |
#exe_name ⇒ Object
26 27 28 |
# File 'lib/cloudscopes/process.rb', line 26 def exe_name File.basename(exe) end |
#procpath(field = nil) ⇒ Object
13 14 15 |
# File 'lib/cloudscopes/process.rb', line 13 def procpath(field = nil) "/proc/#{@id}/#{field}" end |
#uid ⇒ Object
30 31 32 |
# File 'lib/cloudscopes/process.rb', line 30 def uid File.stat(procpath('mem')).uid end |
#user ⇒ Object
34 35 36 |
# File 'lib/cloudscopes/process.rb', line 34 def user Etc.getpwuid(uid).name end |