Module: CitrusMonitor::ProcessMonitor

Includes:
Utils
Defined in:
lib/citrus-monitor/process_monitor.rb

Overview

ProcessMonitor

Instance Method Summary collapse

Methods included from Utils

#get_current_time

Instance Method Details

#get_ps_info(args = {}, &block) ⇒ Object

Get process information by command ‘ps auxw | grep serverId | grep pid’

Options Hash (args):

  • :pid (Integer)
  • :server_id (String)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/citrus-monitor/process_monitor.rb', line 18

def get_ps_info args={}, &block
  return if OS.windows?

  pid = args[:pid]

  EM.system('sh', proc{ |process|
    process.send_data "ps auxw | grep " + pid.to_s + " | grep -v 'grep'\n"
    process.send_data "exit\n"
  }) { |output, status|
    if status.exitstatus == 0
      format args, output, &block
    else
      block.call status, nil if block
    end
  }
end