Class: Cognizant::Process::Conditions::CpuUsage

Inherits:
PollCondition show all
Defined in:
lib/cognizant/process/conditions/cpu_usage.rb

Instance Method Summary collapse

Methods inherited from PollCondition

#format_value, #initialize

Constructor Details

This class inherits a constructor from Cognizant::Process::Conditions::PollCondition

Instance Method Details

#check(value) ⇒ Object



12
13
14
15
16
# File 'lib/cognizant/process/conditions/cpu_usage.rb', line 12

def check(value)
  # Evaluate the value with threshold.
  # The result of this decides condition invoking.
  value > @options[:above].to_f
end

#run(pid) ⇒ Object



7
8
9
10
# File 'lib/cognizant/process/conditions/cpu_usage.rb', line 7

def run(pid)
  # Check for current value for the given process pid.
  Cognizant::System.cpu_usage(pid).to_f
end