diff --git a/lib/facts/debian/architecture.rb b/lib/facts/debian/architecture.rb index 30d6d00f5..2889f03b8 100644 --- a/lib/facts/debian/architecture.rb +++ b/lib/facts/debian/architecture.rb @@ -10,6 +10,7 @@ class Architecture def call_the_resolver fact_value = Facter::Resolvers::Uname.resolve(:machine) fact_value = 'amd64' if fact_value == 'x86_64' + fact_value = fact_value =~ /i[3456]86|pentium/ ? 'i386' : fact_value [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)] end diff --git a/lib/facts/linux/os/architecture.rb b/lib/facts/linux/os/architecture.rb index f4fc81757..eb3cdbac5 100644 --- a/lib/facts/linux/os/architecture.rb +++ b/lib/facts/linux/os/architecture.rb @@ -10,6 +10,8 @@ class Architecture def call_the_resolver fact_value = Facter::Resolvers::Uname.resolve(:machine) + fact_value = fact_value =~ /i[3456]86|pentium/ ? 'i386' : fact_value + [Facter::ResolvedFact.new(FACT_NAME, fact_value), Facter::ResolvedFact.new(ALIASES, fact_value, :legacy)] end end diff --git a/lib/facts/rhel/os/release.rb b/lib/facts/rhel/os/release.rb new file mode 100644 index 000000000..0c26ec078 --- /dev/null +++ b/lib/facts/rhel/os/release.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Facts + module Rhel + module Os + class Release + FACT_NAME = 'os.release' + ALIASES = %w[operatingsystemmajrelease operatingsystemrelease].freeze + + def call_the_resolver + version = determine_release_version + + return Facter::ResolvedFact.new(FACT_NAME, nil) unless version + + [Facter::ResolvedFact.new(FACT_NAME, version), + Facter::ResolvedFact.new(ALIASES.first, version['major'], :legacy), + Facter::ResolvedFact.new(ALIASES.last, version['full'], :legacy)] + end + + def determine_release_version + version = Facter::Resolvers::RedHatRelease.resolve(:version) + + return unless version + + versions = version.split('.') + fact_value = {} + fact_value['full'] = version + fact_value['major'] = versions[0] + fact_value['minor'] = versions[1].gsub(/^0([1-9])/, '\1') if versions[1] + fact_value + end + end + end + end +end diff --git a/lib/resolvers/aix/mountpoints.rb b/lib/resolvers/aix/mountpoints.rb index 80613036a..0f07c8d91 100644 --- a/lib/resolvers/aix/mountpoints.rb +++ b/lib/resolvers/aix/mountpoints.rb @@ -19,7 +19,7 @@ def read_mount(fact_name) @fact_list[:mountpoints] = {} output = Facter::Core::Execution.execute('mount', logger: log) output.split("\n").map do |line| - next if line =~ /\snode\s|---|procfs|ahafs/ + next if line =~ /node|---|procfs|ahafs/ elem = line.split("\s") diff --git a/lib/resolvers/mountpoints_resolver.rb b/lib/resolvers/mountpoints_resolver.rb index 44704a9de..514468a58 100644 --- a/lib/resolvers/mountpoints_resolver.rb +++ b/lib/resolvers/mountpoints_resolver.rb @@ -39,10 +39,10 @@ def read_mounts # rubocop:disable Metrics/AbcSize next if path =~ %r{^/(proc|sys)} && filesystem != 'tmpfs' || filesystem == 'autofs' stats = FilesystemHelper.read_mountpoint_stats(path) - size_bytes = stats.bytes_total - available_bytes = stats.bytes_available + size_bytes = stats.bytes_total.abs + available_bytes = stats.bytes_available.abs - used_bytes = stats.bytes_used + used_bytes = stats.bytes_used.abs total_bytes = used_bytes + available_bytes capacity = FilesystemHelper.compute_capacity(used_bytes, total_bytes) diff --git a/lib/resolvers/processors_resolver.rb b/lib/resolvers/processors_resolver.rb index a9b0baf7b..f7a9df7fa 100644 --- a/lib/resolvers/processors_resolver.rb +++ b/lib/resolvers/processors_resolver.rb @@ -25,6 +25,7 @@ def read_cpuinfo(fact_name) read_processors(cpuinfo_output) # + model names @fact_list[:physical_count] = @fact_list[:physical_processors].uniq.length + @fact_list[:physical_count] = search_in_system_devices if @fact_list[:physical_count].zero? @fact_list[fact_name] end @@ -51,6 +52,12 @@ def construct_models_list(tokens) def count_physical_processors(tokens) @fact_list[:physical_processors] << tokens.last.strip.to_i if tokens.first.strip == 'physical id' end + + def search_in_system_devices + dirs = Dir.entries('/sys/devices/system/cpu').reject { |dir| dir =~ /\.+/ } + + dirs.count { |dir| dir =~ /cpu[0-9]+$/ } + end end end end