class Checkson::Check::Process
Public Class Methods
new(opts = {})
click to toggle source
Calls superclass method
Checkson::Check::Shell::new
# File lib/checkson/checks/process.rb, line 8 def initialize(opts = {}) @opts = opts raise ArgumentError, 'Neither pidfile nor process name given' unless @opts[:pidfile] || @opts[:name] super() end
Public Instance Methods
check()
click to toggle source
# File lib/checkson/checks/process.rb, line 15 def check @opts[:pidfile] ? check_pidfile : check_name end
Protected Instance Methods
check_name()
click to toggle source
# File lib/checkson/checks/process.rb, line 34 def check_name ps = execute('ps auxwww') if @opts[:name].is_a?(Regexp) && ps !~ (@opts[:name]) failed! log("No process found matching regular expression `#{@opts[:name].source}`") elsif !ps.include?(@opts[:name]) failed! log("No process found matching name `#{@opts[:name]}`") end end
check_pidfile()
click to toggle source
# File lib/checkson/checks/process.rb, line 21 def check_pidfile pid = File.read(@opts[:pidfile]).strip execute("kill -0 #{pid} 2>&1") unless $?.exitstatus.zero? failed! log("Process ID #{pid} is not running") end rescue Errno::ENOENT failed! log("Cannot open pidfile: #{@opts[:pidfile]}") end