Sha256: c2a85f33c1db754074c2edf495c9d9e85ec2e76761f5a413528ecc0746a780b1

Contents?: true

Size: 543 Bytes

Versions: 31

Compression:

Stored size: 543 Bytes

Contents

module LitmusPaper
  module Metric
    class CPULoad
      def initialize(weight, facter = Facter)
        @weight = weight
        @facter = facter
      end

      def current_health
        [@weight - (@weight * load_average / processor_count), 0].max
      end

      def processor_count
        @processor_count ||= @facter.value('processorcount').to_i
      end

      def load_average
        @facter.value('loadaverage').split(' ').first.to_f
      end

      def to_s
        "Metric::CPULoad(#{@weight})"
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
litmus_paper-0.9.0 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.8.9 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.8.8 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.8.7 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.8.6 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.8.5 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.8.4 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.8.3 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.8.2 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.8.1 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.8.0 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.7.9 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.7.5 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.7.4 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.7.3 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.7.2 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.7.1 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.7.0 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.6.3 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.6.2 lib/litmus_paper/metric/cpu_load.rb