Class: Procmon::ProcessConditions::CpuUsage
- Inherits:
-
ProcessCondition
- Object
- ProcessCondition
- Procmon::ProcessConditions::CpuUsage
- Defined in:
- lib/procmon/process_conditions/cpu_usage.rb
Instance Attribute Summary
Attributes inherited from ProcessCondition
Instance Method Summary collapse
- #check(value) ⇒ Object
- #description ⇒ Object
-
#initialize(options = {}) ⇒ CpuUsage
constructor
A new instance of CpuUsage.
- #run(pid) ⇒ Object
Methods inherited from ProcessCondition
Constructor Details
#initialize(options = {}) ⇒ CpuUsage
Returns a new instance of CpuUsage.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/procmon/process_conditions/cpu_usage.rb', line 4 def initialize( = {}) super() @below = [:below] @above = [:above] if @below && @above && @below < @above raise "Invalid range for mem check condition" elsif @below.nil? && @above.nil? raise "Invalid range for mem check condition" end end |
Instance Method Details
#check(value) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/procmon/process_conditions/cpu_usage.rb', line 19 def check(value) if @below && @above value < @below && value > @above elsif @below value < @below elsif @above value > @above end end |
#description ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/procmon/process_conditions/cpu_usage.rb', line 29 def description ret = "Cpu usage is " conditions = {} conditions[:below] = @options[:below] if @options[:below] conditions[:above] = @options[:above] if @options[:above] ret += conditions.inspect end |