Class: Bluepill::ProcessConditions::CpuUsage

Inherits:
ProcessCondition show all
Defined in:
lib/bluepill/process_conditions/cpu_usage.rb

Instance Method Summary collapse

Methods inherited from ProcessCondition

#format_value

Constructor Details

#initialize(options = {}) ⇒ CpuUsage

Returns a new instance of CpuUsage.



5
6
7
# File 'lib/bluepill/process_conditions/cpu_usage.rb', line 5

def initialize(options = {})
  @below = options[:below]
end

Instance Method Details

#check(value) ⇒ Object



14
15
16
# File 'lib/bluepill/process_conditions/cpu_usage.rb', line 14

def check(value)
  value < @below
end

#run(pid) ⇒ Object



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

def run(pid)
  # third col in the ps axu output
  System.cpu_usage(pid).to_f
end