Sha256: 3abeee3ce2f563454fbc49b6c4e71fb7df6321045186c50c3de1940798482e45

Contents?: true

Size: 638 Bytes

Versions: 2

Compression:

Stored size: 638 Bytes

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    class LoadAverages < BaseResolver
      @semaphore = Mutex.new
      @fact_list ||= {}
      class << self
        private

        def post_resolve(fact_name)
          @fact_list.fetch(fact_name) { read_load_averages(fact_name) }
        end

        def read_load_averages(fact_name)
          require_relative 'utils/ffi/load_averages'

          log.debug('loading cpu load averages')
          @fact_list[:load_averages] = %w[1m 5m 15m].zip(Utils::Ffi::LoadAverages.read_load_averages).to_h

          @fact_list[fact_name]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
facter-4.0.36 lib/facter/resolvers/load_averages.rb
facter-4.0.35 lib/facter/resolvers/load_averages.rb