Class: Procmon::ProcessConditions::ProcessHealth

Inherits:
ProcessCondition show all
Defined in:
lib/procmon/process_conditions/process_health.rb

Instance Attribute Summary

Attributes inherited from ProcessCondition

#actions

Instance Method Summary collapse

Methods inherited from ProcessCondition

#format_value

Constructor Details

#initialize(options = {}) ⇒ ProcessHealth

Returns a new instance of ProcessHealth.



4
5
6
7
8
9
10
# File 'lib/procmon/process_conditions/process_health.rb', line 4

def initialize(options = {})
  super(options)
  @status = options[:status]
  if @status != "up" and @status != "down"
    raise "Don't know what to do for process_health check. You need to specify :status => \"down\" or :status => \"up\""
  end
end

Instance Method Details

#check(value) ⇒ Object



17
18
19
# File 'lib/procmon/process_conditions/process_health.rb', line 17

def check(value)
  !(value ^ (@status == "up"))
end

#descriptionObject



21
22
23
# File 'lib/procmon/process_conditions/process_health.rb', line 21

def description
  "Checking to see if is_up = #{@is_up}"
end

#run(pid) ⇒ Object



12
13
14
15
# File 'lib/procmon/process_conditions/process_health.rb', line 12

def run(pid)
  return false if pid.nil?
  System.pid_alive?(pid)
end