Class: EventedBluepill::ProcessConditions::CpuUsage

Inherits:
ProcessCondition
  • Object
show all
Defined in:
lib/evented_bluepill/process_conditions/cpu_usage.rb

Instance Attribute Summary

Attributes inherited from ProcessCondition

#every, #fires, #logger, #name, #process, #process_condition

Instance Method Summary collapse

Methods inherited from ProcessCondition

#clear_history!, #format_value, #to_s

Constructor Details

#initialize(name, process, options = {}) ⇒ CpuUsage

Returns a new instance of CpuUsage.



9
10
11
12
13
# File 'lib/evented_bluepill/process_conditions/cpu_usage.rb', line 9

def initialize(name, process, options = {})
  @below = options[:below]

  super
end

Instance Method Details

#check(value) ⇒ Object



20
21
22
# File 'lib/evented_bluepill/process_conditions/cpu_usage.rb', line 20

def check(value)
  value < @below
end

#runObject



15
16
17
18
# File 'lib/evented_bluepill/process_conditions/cpu_usage.rb', line 15

def run
  # third col in the ps axu output
  EventedBluepill::System.cpu_usage(process.actual_pid).to_f
end