class ProcessObserver::LinuxProcess
Class representing process in Unix.
Attributes
@return [String] command which launched process.
@return [Integer] process ID.
@return [Integer, nil] amount of used CPU memory in KB.
@return [String, nil] process status.
@return [String, nil] amount of time process is running.
Public Class Methods
Initialize new process.
@param options [Hash]
@option options [String] comm command which launched process. @option options [Integer] pid process ID. @option options [String, nil] stat process status. @option options [String, nil] time amount of time process is running. @option options [Integer, nil] rss amount of used CPU memory in KB.
ProcessObserver::Process::new
# File lib/process_observer/process.rb, line 191 def initialize(options) @comm = options[:comm].to_s @pid = options[:pid].to_i @stat = options[:stat] ? options[:stat].to_s : nil @time = options[:time] ? options[:time].to_s : nil @rss = options[:rss] ? options[:rss].to_i : nil super( name: @comm, pid: @pid, memory: @rss ) end
Public Instance Methods
Compare with other process by PID.
# File lib/process_observer/process.rb, line 226 def ==(other) LinuxProcess === other && other.pid == @pid end
Inspect all stored data.
@param [String] splitter
@return [String] all accessable info in human-readable form.
# File lib/process_observer/process.rb, line 217 def inspect(splitter = "; ") to_s + (@stat ? "#{splitter}Status: #{@stat}" : "") + (@time ? "#{splitter}Time running: #{@time}" : "") + (@rss ? "#{splitter}Memory: #{@rss} KB" : "") end
@return [String] PID and command of process.
# File lib/process_observer/process.rb, line 207 def to_s "Process ##{@pid} #{@comm}" end