Sha256: 2bf548a3411b774aea171dcd05d0c1e5b12916e41f556ac3f33a4b42a42eaca2

Contents?: true

Size: 551 Bytes

Versions: 3

Compression:

Stored size: 551 Bytes

Contents

module LitmusPaper
  module Metric
    class CPULoad
      def initialize(weight, facter = DeferredFacter)
        @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

3 entries across 3 versions & 1 rubygems

Version Path
litmus_paper-0.2.2 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.2.1 lib/litmus_paper/metric/cpu_load.rb
litmus_paper-0.2.0 lib/litmus_paper/metric/cpu_load.rb