Sha256: f8378d95cfcd043a8862ecfdc8a426a637f3f1d7c9a93823d4cc255b88d40726

Contents?: true

Size: 1.26 KB

Versions: 22

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    module Bsd
      class Processors < BaseResolver
        init_resolver
        @log = Facter::Log.new(self)

        class << self
          private

          def post_resolve(fact_name, _options)
            @fact_list.fetch(fact_name) { collect_processors_info(fact_name) }
          end

          def collect_processors_info(fact_name)
            require 'facter/resolvers/bsd/ffi/ffi_helper'

            count = logical_count
            model = processor_model
            speed = processor_speed

            @fact_list[:logical_count] = count
            @fact_list[:models] = Array.new(count, model) if count && model
            @fact_list[:speed] = speed * 1000 * 1000 if speed

            @fact_list[fact_name]
          end

          CTL_HW = 6
          HW_MODEL = 2
          HW_NCPU = 3
          HW_CPUSPEED = 12

          def processor_model
            Facter::Bsd::FfiHelper.sysctl(:string, [CTL_HW, HW_MODEL])
          end

          def logical_count
            Facter::Bsd::FfiHelper.sysctl(:uint32_t, [CTL_HW, HW_NCPU])
          end

          def processor_speed
            Facter::Bsd::FfiHelper.sysctl(:uint32_t, [CTL_HW, HW_CPUSPEED])
          end
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
facter-4.3.1 lib/facter/resolvers/bsd/processors.rb
facter-4.3.0 lib/facter/resolvers/bsd/processors.rb
facter-4.2.14 lib/facter/resolvers/bsd/processors.rb
facter-4.2.13 lib/facter/resolvers/bsd/processors.rb
facter-4.2.12 lib/facter/resolvers/bsd/processors.rb
facter-4.2.11 lib/facter/resolvers/bsd/processors.rb
facter-4.2.10 lib/facter/resolvers/bsd/processors.rb
facter-4.2.9 lib/facter/resolvers/bsd/processors.rb
facter-4.2.8 lib/facter/resolvers/bsd/processors.rb
facter-4.2.7 lib/facter/resolvers/bsd/processors.rb
facter-4.2.6 lib/facter/resolvers/bsd/processors.rb
facter-4.2.5 lib/facter/resolvers/bsd/processors.rb
facter-4.2.4 lib/facter/resolvers/bsd/processors.rb
facter-4.2.3 lib/facter/resolvers/bsd/processors.rb
facter-4.2.2 lib/facter/resolvers/bsd/processors.rb
facter-4.2.1 lib/facter/resolvers/bsd/processors.rb
facter-4.2.0 lib/facter/resolvers/bsd/processors.rb
facter-4.1.1 lib/facter/resolvers/bsd/processors.rb
facter-4.1.0 lib/facter/resolvers/bsd/processors.rb
facter-4.0.52 lib/facter/resolvers/bsd/processors.rb