module ProcessObserver::Linux
Module with methods to interact with Linux
.
Constants
- EXE
Process
list executable.- OUTPUT_FORMAT
Output format.
Public Class Methods
call(options = "-A")
click to toggle source
Call processes list executable with provided options string.
@param options [String] options string.
@return [Array<Process>] array of processes.
# File lib/process_observer/linux.rb, line 21 def self.call(options = "-A") raise ArgumentError, "Provide options string", caller if options.to_s.empty? command = "#{EXE} #{options} #{OUTPUT_FORMAT}" Log.debug "Executing: #{command}" re = `#{command}`.chomp csv = CSV.parse(re.each_line.map { |line| line.strip.squeeze(" ") }.join("\n"), col_sep: " ") enum = csv.to_a.drop(1) # Skip header enum.map do |data| LinuxProcess.new( pid: data[0], comm: data[1], stat: data[2], time: data[3], rss: data[4] ) end end