class Facter::Resolvers::Macosx::Processors
Constants
- ITEMS
Private Class Methods
build_cores_per_socket(hash)
click to toggle source
# File lib/facter/resolvers/macosx/processors.rb, line 62 def build_cores_per_socket(hash) @fact_list[:cores_per_socket] = hash[ITEMS[:cores_per_socket]].to_i end
build_fact_list(hash)
click to toggle source
# File lib/facter/resolvers/macosx/processors.rb, line 37 def build_fact_list(hash) build_logical_count(hash) build_physical_count(hash) build_models(hash) build_speed(hash) build_cores_per_socket(hash) build_threads_per_core(hash) end
build_logical_count(hash)
click to toggle source
# File lib/facter/resolvers/macosx/processors.rb, line 46 def build_logical_count(hash) @fact_list[:logicalcount] = hash[ITEMS[:logical_count]].to_i end
build_models(hash)
click to toggle source
# File lib/facter/resolvers/macosx/processors.rb, line 54 def build_models(hash) @fact_list[:models] = Array.new(@fact_list[:logicalcount].to_i, hash[ITEMS[:brand]]) end
build_physical_count(hash)
click to toggle source
# File lib/facter/resolvers/macosx/processors.rb, line 50 def build_physical_count(hash) @fact_list[:physicalcount] = hash[ITEMS[:physical_count]].to_i end
build_speed(hash)
click to toggle source
# File lib/facter/resolvers/macosx/processors.rb, line 58 def build_speed(hash) @fact_list[:speed] = hash[ITEMS[:speed]].to_i end
build_threads_per_core(hash)
click to toggle source
# File lib/facter/resolvers/macosx/processors.rb, line 66 def build_threads_per_core(hash) @fact_list[:threads_per_core] = hash[ITEMS[:threads_per_core]].to_i / hash[ITEMS[:cores_per_socket]].to_i end
post_resolve(fact_name, _options)
click to toggle source
:logicalcount :models :physicalcount :speed :cores_per_socket :threads_per_core
# File lib/facter/resolvers/macosx/processors.rb, line 26 def post_resolve(fact_name, _options) @fact_list.fetch(fact_name) { read_processor_data(fact_name) } end
read_processor_data(fact_name)
click to toggle source
# File lib/facter/resolvers/macosx/processors.rb, line 30 def read_processor_data(fact_name) output = Facter::Core::Execution.execute("sysctl #{ITEMS.values.join(' ')}", logger: log) processors_hash = Hash[*output.split("\n").collect { |v| [v.split(': ')[0], v.split(': ')[1]] }.flatten] build_fact_list(processors_hash) @fact_list[fact_name] end