Class: Eye::Checker::Cpu

Inherits:
Eye::Checker show all
Defined in:
lib/eye/checker/cpu.rb

Constant Summary

Constants inherited from Eye::Checker

TYPES

Instance Attribute Summary

Attributes inherited from Eye::Checker

#options, #pid, #type, #value, #values

Attributes included from Dsl::Validation

#defaults, #should_bes, #validates, #variants

Attributes included from Logger::Helpers

#logger

Instance Method Summary collapse

Methods inherited from Eye::Checker

#check, create, get_class, #initialize, #last_human_values, #max_tries, #min_tries, #previous_value, validate!

Methods included from Dsl::Validation

#inherited, #param, #validate

Constructor Details

This class inherits a constructor from Eye::Checker

Instance Method Details

#check_nameObject



7
8
9
# File 'lib/eye/checker/cpu.rb', line 7

def check_name
  @check_name ||= "cpu(#{human_value(below)})"
end

#get_valueObject



11
12
13
# File 'lib/eye/checker/cpu.rb', line 11

def get_value
  Eye::SystemResources.cpu(@pid).to_i # nil => 0
end

#good?(value) ⇒ Boolean

Returns:



19
20
21
22
23
24
25
# File 'lib/eye/checker/cpu.rb', line 19

def good?(value)
  if below
    value < below
  else
    true
  end
end

#human_value(value) ⇒ Object



15
16
17
# File 'lib/eye/checker/cpu.rb', line 15

def human_value(value)
  "#{value}%"
end