Sha256: 952cf22cc031a4c4051047642e326ddd0efca95b01fe72882a1a534e8cf4052c

Contents?: true

Size: 694 Bytes

Versions: 15

Compression:

Stored size: 694 Bytes

Contents

# frozen_string_literal: true

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

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

          def read_load_averages_file(fact_name)
            output = Facter::Core::Execution.execute('sysctl -n vm.loadavg', logger: log)
            @fact_list[:load_averages] = {}.tap { |h| _, h['1m'], h['5m'], h['15m'], = output.split.map(&:to_f) }

            @fact_list[fact_name]
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
facter-4.0.36 lib/facter/resolvers/macosx/load_averages_resolver.rb
facter-4.0.35 lib/facter/resolvers/macosx/load_averages_resolver.rb
facter-4.0.34 lib/facter/resolvers/macosx/load_averages_resolver.rb
facter-4.0.33 lib/facter/resolvers/macosx/load_averages_resolver.rb
facter-4.0.32 lib/facter/resolvers/macosx/load_averages_resolver.rb
facter-4.0.31 lib/facter/resolvers/macosx/load_averages_resolver.rb
facter-4.0.30 lib/facter/resolvers/macosx/load_averages_resolver.rb
facter-4.0.29 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.28 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.26 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.25 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.24 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.23 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.22 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.21 lib/resolvers/macosx/load_averages_resolver.rb