Sha256: 0c65cb068c1af5134c3f679fd5db1831df19b9c9b7e427dd0bd8774585c42d6e

Contents?: true

Size: 1.8 KB

Versions: 91

Compression:

Stored size: 1.8 KB

Contents

# Fact: processors
#
# Purpose:
#   Provide additional facts about the machine's CPUs, including:
#   Models: A list of processors present on the system.
#   Count:  The number of hardware threads.
#   Physicalcount: The number of physical processors.
#   Speed: The speed of the processors on the system.
#
#   This fact is structured. These values are returned as a group of key-value pairs.
#
# Resolution:
#   Linux and kFreeBSD parse `/proc/cpuinfo` for each processor.
#   AIX parses the output of `lsdev` for its processor section.
#   Solaris parses the output of `kstat` for each processor.
#   OpenBSD uses the sysctl variables `hw.model` and `hw.ncpu` for the CPU model
#   and the CPU count respectively.
#   Darwin utilizes the system profiler to collect the physical CPU count and speed.
#
# Caveats:
#   The 'speed' sub-fact is not currently supported on all platforms.

require 'facter/processors/os'

Facter.add(:processors, :type => :aggregate) do
  confine do
    !os.nil?
  end

  def os
    @os ||= Facter::Processors.implementation
  end

  chunk(:models) do
    processor_hash = {}
    processor_list = os.get_processor_list
    if processor_list.length > 0
      processor_hash["models"] = processor_list
      processor_hash
    end
  end

  chunk(:count) do
    processor_hash = {}
    if (processor_count = os.get_processor_count)
      processor_hash["count"] = processor_count
      processor_hash
    end
  end

  chunk(:physicalcount) do
    processor_hash = {}
    if (physical_processor_count = os.get_physical_processor_count)
      processor_hash["physicalcount"] = physical_processor_count
      processor_hash
    end
  end

  chunk(:speed) do
    processor_hash = {}
    if (processor_speed = os.get_processor_speed)
      processor_hash["speed"] = processor_speed
      processor_hash
    end
  end
end

Version data entries

91 entries across 91 versions & 2 rubygems

Version Path
facter-2.5.7 lib/facter/processors.rb
facter-2.5.7-x86-mingw32 lib/facter/processors.rb
facter-2.5.7-x64-mingw32 lib/facter/processors.rb
facter-2.5.7-universal-darwin lib/facter/processors.rb
facter-2.5.6-x86-mingw32 lib/facter/processors.rb
facter-2.5.6-x64-mingw32 lib/facter/processors.rb
facter-2.5.6-universal-darwin lib/facter/processors.rb
facter-2.5.6 lib/facter/processors.rb
facter-2.5.5-x86-mingw32 lib/facter/processors.rb
facter-2.5.5-x64-mingw32 lib/facter/processors.rb
facter-2.5.5-universal-darwin lib/facter/processors.rb
facter-2.5.5 lib/facter/processors.rb
facter-2.5.4-x86-mingw32 lib/facter/processors.rb
facter-2.5.4-x64-mingw32 lib/facter/processors.rb
facter-2.5.4-universal-darwin lib/facter/processors.rb
facter-2.5.4 lib/facter/processors.rb
bolt-0.24.0 vendored/facter/lib/facter/processors.rb
bolt-0.23.0 vendored/facter/lib/facter/processors.rb
bolt-0.22.0 vendored/facter/lib/facter/processors.rb
bolt-0.21.8 vendored/facter/lib/facter/processors.rb