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.6.1 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.6.0 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.5.0 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.4.0 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.3.5 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.3.3 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.3.2 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.3.1 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.3.0 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.1.0 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.0.3 lib/litmus_paper/metric/cpu_load.rb