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.



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

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

Instance Method Details

#check(value) ⇒ Object



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

def check(value)
  value < @below
end

#run(pid) ⇒ Object



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

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