Sha256: 4bfafcfaa07866d41a9a39f94599737478e2f74b1b4b39b20aa082e8f44e9e2a

Contents?: true

Size: 710 Bytes

Versions: 14

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    module Macosx
      class LoadAverages < BaseResolver
        @log = Facter::Log.new(self)
        @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, _status = Open3.capture2('sysctl -n vm.loadavg')
            @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

14 entries across 14 versions & 1 rubygems

Version Path
facter-4.0.20 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.19 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.18 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.17 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.16 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.15 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.14 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.13 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.12 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.11 lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.10.pre lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.9.pre lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.8.pre lib/resolvers/macosx/load_averages_resolver.rb
facter-4.0.7.pre lib/resolvers/macosx/load_averages_resolver.rb