Class: IPVSLitmus::Metric::CPULoad
- Inherits:
-
Object
- Object
- IPVSLitmus::Metric::CPULoad
- Defined in:
- lib/ipvs_litmus/metric/cpu_load.rb
Instance Method Summary collapse
- #current_health ⇒ Object
-
#initialize(weight, facter = Facter) ⇒ CPULoad
constructor
A new instance of CPULoad.
- #load_average ⇒ Object
- #processor_count ⇒ Object
Constructor Details
#initialize(weight, facter = Facter) ⇒ CPULoad
Returns a new instance of CPULoad.
4 5 6 7 |
# File 'lib/ipvs_litmus/metric/cpu_load.rb', line 4 def initialize(weight, facter = Facter) @weight = weight @facter = facter end |
Instance Method Details
#current_health ⇒ Object
9 10 11 |
# File 'lib/ipvs_litmus/metric/cpu_load.rb', line 9 def current_health [@weight - (@weight * load_average / processor_count), 0].max end |
#load_average ⇒ Object
17 18 19 |
# File 'lib/ipvs_litmus/metric/cpu_load.rb', line 17 def load_average @facter.value('loadaverage').split(' ').first.to_f end |
#processor_count ⇒ Object
13 14 15 |
# File 'lib/ipvs_litmus/metric/cpu_load.rb', line 13 def processor_count @processor_count ||= @facter.value('processorcount').to_i end |