facter 1.7.3 → 1.7.4.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of facter might be problematic. Click here for more details.
- data/Gemfile +10 -7
- data/bin/facter +0 -58
- data/ext/build_defaults.yaml +2 -2
- data/ext/debian/rules +1 -1
- data/lib/facter/application.rb +69 -24
- data/lib/facter/architecture.rb +14 -1
- data/lib/facter/operatingsystemrelease.rb +3 -3
- data/lib/facter/util/architecture.rb +19 -0
- data/lib/facter/util/collection.rb +13 -7
- data/lib/facter/util/config.rb +11 -5
- data/lib/facter/util/ip/windows.rb +2 -2
- data/lib/facter/util/loader.rb +1 -1
- data/lib/facter/util/memory.rb +19 -3
- data/lib/facter/util/parser.rb +13 -5
- data/lib/facter/util/processor.rb +2 -0
- data/lib/facter/util/resolution.rb +3 -3
- data/lib/facter/util/unix_root.rb +5 -0
- data/lib/facter/util/windows_root.rb +37 -0
- data/lib/facter/version.rb +1 -1
- data/lib/facter/virtual.rb +20 -10
- data/spec/fixtures/cpuinfo/amd64twentyfour +600 -0
- data/spec/fixtures/hpux/machinfo/superdome-server-SD32B +53 -0
- data/spec/fixtures/hpux/machinfo/superdome2-16s +31 -0
- data/spec/fixtures/processorcount/solaris-psrinfo +24 -0
- data/spec/lib/facter_spec/cpuinfo.rb +15 -0
- data/spec/unit/architecture_spec.rb +8 -0
- data/spec/unit/ec2_spec.rb +1 -1
- data/spec/unit/memory_spec.rb +27 -4
- data/spec/unit/operatingsystemrelease_spec.rb +2 -2
- data/spec/unit/processor_spec.rb +120 -151
- data/spec/unit/util/collection_spec.rb +17 -1
- data/spec/unit/util/config_spec.rb +9 -0
- data/spec/unit/util/ip/windows_spec.rb +34 -2
- data/spec/unit/util/loader_spec.rb +1 -1
- data/spec/unit/util/parser_spec.rb +65 -51
- data/spec/unit/util/processor_spec.rb +7 -8
- data/spec/unit/util/resolution_spec.rb +3 -3
- data/spec/unit/virtual_spec.rb +18 -0
- metadata +491 -478
data/Gemfile
CHANGED
@@ -14,21 +14,24 @@ end
|
|
14
14
|
|
15
15
|
group :development, :test do
|
16
16
|
gem 'rake'
|
17
|
-
gem 'facter', ">= 1.0.0", :path => File.expand_path("..", __FILE__)
|
18
17
|
gem 'rspec', "~> 2.11.0"
|
19
18
|
gem 'mocha', "~> 0.10.5"
|
20
|
-
gem 'json', "~> 1.7"
|
19
|
+
gem 'json', "~> 1.7", :platforms => :ruby
|
21
20
|
gem 'puppetlabs_spec_helper'
|
22
21
|
end
|
23
22
|
|
24
23
|
platform :mswin, :mingw do
|
25
|
-
gem "
|
26
|
-
gem "
|
27
|
-
gem "
|
28
|
-
gem "
|
29
|
-
gem "
|
24
|
+
gem "ffi", "1.9.0", :require => false
|
25
|
+
gem "sys-admin", "1.5.6", :require => false
|
26
|
+
gem "win32-api", "1.4.8", :require => false
|
27
|
+
gem "win32-dir", "0.4.3", :require => false
|
28
|
+
gem "windows-api", "0.4.2", :require => false
|
29
|
+
gem "windows-pr", "1.2.2", :require => false
|
30
|
+
gem "win32console", "1.3.2", :require => false
|
30
31
|
end
|
31
32
|
|
33
|
+
gem 'facter', ">= 1.0.0", :path => File.expand_path("..", __FILE__)
|
34
|
+
|
32
35
|
if File.exists? "#{__FILE__}.local"
|
33
36
|
eval(File.read("#{__FILE__}.local"), binding)
|
34
37
|
end
|
data/bin/facter
CHANGED
@@ -1,62 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# = Synopsis
|
4
|
-
#
|
5
|
-
# Collect and display facts about the system.
|
6
|
-
#
|
7
|
-
# = Usage
|
8
|
-
#
|
9
|
-
# facter [-d|--debug] [-h|--help] [-p|--puppet] [-v|--version] [-y|--yaml] [-j|--json] [--external-dir DIR] [--no-external-dir] [fact] [fact] [...]
|
10
|
-
#
|
11
|
-
# = Description
|
12
|
-
#
|
13
|
-
# Collect and display facts about the current system. The library behind
|
14
|
-
# Facter is easy to expand, making Facter an easy way to collect information
|
15
|
-
# about a system from within the shell or within Ruby.
|
16
|
-
#
|
17
|
-
# If no facts are specifically asked for, then all facts will be returned.
|
18
|
-
#
|
19
|
-
# = Options
|
20
|
-
#
|
21
|
-
# yaml::
|
22
|
-
# Emit facts in YAML format.
|
23
|
-
#
|
24
|
-
# json::
|
25
|
-
# Emit facts in JSON format.
|
26
|
-
#
|
27
|
-
# puppet::
|
28
|
-
# Load the Puppet libraries, thus allowing Facter to load Puppet-specific facts.
|
29
|
-
#
|
30
|
-
# version::
|
31
|
-
# Print the version and exit.
|
32
|
-
#
|
33
|
-
# help::
|
34
|
-
# Print this help message.
|
35
|
-
#
|
36
|
-
# debug::
|
37
|
-
# Enable debugging.
|
38
|
-
#
|
39
|
-
# trace::
|
40
|
-
# Enable backtraces.
|
41
|
-
#
|
42
|
-
# timing::
|
43
|
-
# Enable timing.
|
44
|
-
#
|
45
|
-
# facts.d::
|
46
|
-
# The directory to use for external facts.
|
47
|
-
#
|
48
|
-
# = Example
|
49
|
-
#
|
50
|
-
# facter kernel
|
51
|
-
#
|
52
|
-
# = Author
|
53
|
-
#
|
54
|
-
# Luke Kanies
|
55
|
-
#
|
56
|
-
# = Copyright
|
57
|
-
#
|
58
|
-
# Copyright (c) 2011 Puppet Labs, Inc
|
59
|
-
# Licensed under the Apache 2.0 license
|
60
2
|
|
61
3
|
# Bundler and rubygems maintain a set of directories from which to
|
62
4
|
# load gems. If Bundler is loaded, let it determine what can be
|
data/ext/build_defaults.yaml
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
packaging_url: 'git://github.com/puppetlabs/packaging.git --branch=master'
|
3
3
|
packaging_repo: 'packaging'
|
4
4
|
default_cow: 'base-squeeze-i386.cow'
|
5
|
-
cows: 'base-lucid-i386.cow base-lucid-amd64.cow base-precise-i386.cow base-precise-amd64.cow base-quantal-i386.cow base-quantal-amd64.cow base-raring-i386.cow base-raring-amd64.cow base-sid-i386.cow base-sid-amd64.cow base-squeeze-i386.cow base-squeeze-amd64.cow base-stable-i386.cow base-stable-amd64.cow base-testing-i386.cow base-testing-amd64.cow base-unstable-i386.cow base-unstable-amd64.cow base-wheezy-i386.cow base-wheezy-amd64.cow'
|
5
|
+
cows: 'base-lucid-i386.cow base-lucid-amd64.cow base-precise-i386.cow base-precise-amd64.cow base-quantal-i386.cow base-quantal-amd64.cow base-raring-i386.cow base-raring-amd64.cow base-saucy-i386.cow base-saucy-amd64.cow base-sid-i386.cow base-sid-amd64.cow base-squeeze-i386.cow base-squeeze-amd64.cow base-stable-i386.cow base-stable-amd64.cow base-testing-i386.cow base-testing-amd64.cow base-unstable-i386.cow base-unstable-amd64.cow base-wheezy-i386.cow base-wheezy-amd64.cow'
|
6
6
|
pbuild_conf: '/etc/pbuilderrc'
|
7
7
|
packager: 'puppetlabs'
|
8
8
|
gpg_name: 'info@puppetlabs.com'
|
9
9
|
gpg_key: '4BD6EC30'
|
10
10
|
sign_tar: FALSE
|
11
11
|
# a space separated list of mock configs
|
12
|
-
final_mocks: 'pl-el-5-i386 pl-el-5-x86_64 pl-el-6-i386 pl-el-6-x86_64 pl-fedora-
|
12
|
+
final_mocks: 'pl-el-5-i386 pl-el-5-x86_64 pl-el-6-i386 pl-el-6-x86_64 pl-fedora-18-i386 pl-fedora-18-x86_64 pl-fedora-19-i386 pl-fedora-19-x86_64 pl-fedora-20-i386 pl-fedora-20-x86_64'
|
13
13
|
yum_host: 'yum.puppetlabs.com'
|
14
14
|
yum_repo_path: '/opt/repository/yum/'
|
15
15
|
build_gem: TRUE
|
data/ext/debian/rules
CHANGED
@@ -7,4 +7,4 @@ LIBDIR=$(shell /usr/bin/ruby -rrbconfig -e 'puts RbConfig::CONFIG["vendordir"]')
|
|
7
7
|
BINDIR=$(shell /usr/bin/ruby -rrbconfig -e 'puts RbConfig::CONFIG["bindir"]')
|
8
8
|
|
9
9
|
binary-install/facter::
|
10
|
-
/usr/bin/ruby install.rb --sitelibdir=$(LIBDIR) --bindir=$(BINDIR) --ruby=/usr/bin/ruby --destdir=$(CURDIR)/debian/$(cdbs_curpkg) --quick
|
10
|
+
/usr/bin/ruby install.rb --sitelibdir=$(LIBDIR) --bindir=$(BINDIR) --ruby=/usr/bin/ruby --destdir=$(CURDIR)/debian/$(cdbs_curpkg) --quick --man
|
data/lib/facter/application.rb
CHANGED
@@ -93,35 +93,80 @@ module Facter
|
|
93
93
|
# @return [Hash] options hash
|
94
94
|
def self.parse(argv)
|
95
95
|
options = {}
|
96
|
-
OptionParser.new do |opts|
|
97
|
-
opts.
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
96
|
+
parser = OptionParser.new do |opts|
|
97
|
+
opts.banner = <<-BANNER
|
98
|
+
Synopsis
|
99
|
+
========
|
100
|
+
|
101
|
+
Collect and display facts about the system.
|
102
|
+
|
103
|
+
Usage
|
104
|
+
=====
|
105
|
+
|
106
|
+
facter [-d|--debug] [-h|--help] [-p|--puppet] [-v|--version] [-y|--yaml] [-j|--json] [--external-dir DIR] [--no-external-dir] [fact] [fact] [...]
|
107
|
+
|
108
|
+
Description
|
109
|
+
===========
|
110
|
+
|
111
|
+
Collect and display facts about the current system. The library behind
|
112
|
+
Facter is easy to expand, making Facter an easy way to collect information
|
113
|
+
about a system from within the shell or within Ruby.
|
114
|
+
|
115
|
+
If no facts are specifically asked for, then all facts will be returned.
|
116
|
+
|
117
|
+
EXAMPLE
|
118
|
+
=======
|
119
|
+
facter kernel
|
120
|
+
|
121
|
+
AUTHOR
|
122
|
+
======
|
123
|
+
Luke Kanies
|
124
|
+
|
125
|
+
COPYRIGHT
|
126
|
+
=========
|
127
|
+
Copyright (c) 2011-2012 Puppet Labs, Inc Licensed under the Apache 2.0 license
|
128
|
+
|
129
|
+
USAGE
|
130
|
+
=====
|
131
|
+
BANNER
|
132
|
+
opts.on("-y",
|
133
|
+
"--yaml",
|
134
|
+
"Emit facts in YAML format.") { |v| options[:yaml] = v }
|
135
|
+
opts.on("-j",
|
136
|
+
"--json",
|
137
|
+
"Emit facts in JSON format.") { |v| options[:json] = v }
|
138
|
+
opts.on("--trace",
|
139
|
+
"Enable backtraces.") { |v| options[:trace] = v }
|
140
|
+
opts.on("--external-dir DIR",
|
141
|
+
"The directory to use for external facts.") { |v| create_directory_loader(v) }
|
142
|
+
opts.on("--no-external-dir",
|
143
|
+
"Turn off external facts.") { |v| create_nothing_loader }
|
144
|
+
opts.on("-d",
|
145
|
+
"--debug",
|
146
|
+
"Enable debugging.") { |v| Facter.debugging(1) }
|
147
|
+
opts.on("-t",
|
148
|
+
"--timing",
|
149
|
+
"Enable timing.") { |v| Facter.timing(1) }
|
150
|
+
opts.on("-p",
|
151
|
+
"--puppet",
|
152
|
+
"Load the Puppet libraries, thus allowing Facter to load Puppet-specific facts.") { |v| load_puppet }
|
153
|
+
|
154
|
+
opts.on_tail("-v",
|
155
|
+
"--version",
|
156
|
+
"Print the version and exit.") do
|
107
157
|
puts Facter.version
|
108
158
|
exit(0)
|
109
159
|
end
|
110
160
|
|
111
|
-
opts.on_tail("-h",
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
rescue LoadError
|
117
|
-
$stderr.puts "No help available unless your RDoc has RDoc.usage"
|
118
|
-
exit(1)
|
119
|
-
rescue => e
|
120
|
-
$stderr.puts "fatal: #{e}"
|
121
|
-
exit(1)
|
122
|
-
end
|
161
|
+
opts.on_tail("-h",
|
162
|
+
"--help",
|
163
|
+
"Print this help message.") do
|
164
|
+
puts parser
|
165
|
+
exit(0)
|
123
166
|
end
|
124
|
-
end
|
167
|
+
end
|
168
|
+
|
169
|
+
parser.parse!(argv)
|
125
170
|
|
126
171
|
options
|
127
172
|
rescue OptionParser::InvalidOption => e
|
data/lib/facter/architecture.rb
CHANGED
@@ -4,18 +4,31 @@
|
|
4
4
|
# Return the CPU hardware architecture.
|
5
5
|
#
|
6
6
|
# Resolution:
|
7
|
-
# On OpenBSD, Linux and Debian's kfreebsd, use the hardwaremodel fact.
|
7
|
+
# On non-AIX IBM, OpenBSD, Linux and Debian's kfreebsd, use the hardwaremodel fact.
|
8
|
+
# On AIX get the arch value from lsattr -El proc0 -a type
|
8
9
|
# Gentoo and Debian call "x86_86" "amd64".
|
9
10
|
# Gentoo also calls "i386" "x86".
|
10
11
|
#
|
11
12
|
# Caveats:
|
12
13
|
#
|
13
14
|
|
15
|
+
require 'facter/util/architecture'
|
16
|
+
|
14
17
|
Facter.add(:architecture) do
|
15
18
|
setcode do
|
16
19
|
model = Facter.value(:hardwaremodel)
|
17
20
|
case model
|
18
21
|
# most linuxen use "x86_64"
|
22
|
+
when /IBM*/
|
23
|
+
case Facter.value(:operatingsystem)
|
24
|
+
when "AIX"
|
25
|
+
arch = Facter::Util::Architecture.lsattr
|
26
|
+
if (match = arch.match /type\s(\S+)\s/)
|
27
|
+
match[1]
|
28
|
+
end
|
29
|
+
else
|
30
|
+
model
|
31
|
+
end
|
19
32
|
when "x86_64"
|
20
33
|
case Facter.value(:operatingsystem)
|
21
34
|
when "Debian", "Gentoo", "GNU/kFreeBSD", "Ubuntu"
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Resolution:
|
6
6
|
# On RedHat derivatives, returns their '/etc/<variant>-release' file.
|
7
7
|
# On Debian, returns '/etc/debian_version'.
|
8
|
-
# On Ubuntu, parses '/etc/
|
8
|
+
# On Ubuntu, parses '/etc/lsb-release' for the release version.
|
9
9
|
# On Suse, derivatives, parses '/etc/SuSE-release' for a selection of version
|
10
10
|
# information.
|
11
11
|
# On Slackware, parses '/etc/slackware-version'.
|
@@ -61,8 +61,8 @@ end
|
|
61
61
|
Facter.add(:operatingsystemrelease) do
|
62
62
|
confine :operatingsystem => %w{Ubuntu}
|
63
63
|
setcode do
|
64
|
-
if release = Facter::Util::FileRead.read('/etc/
|
65
|
-
if match = release.match(/
|
64
|
+
if release = Facter::Util::FileRead.read('/etc/lsb-release')
|
65
|
+
if match = release.match(/DISTRIB_RELEASE=((\d+.\d+)(\.(\d+))?)/)
|
66
66
|
# Return only the major and minor version numbers. This behavior must
|
67
67
|
# be preserved for compatibility reasons.
|
68
68
|
match[2]
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# A module to help test architecture facts on non-AIX test hardware
|
2
|
+
|
3
|
+
module Facter::Util::Architecture
|
4
|
+
##
|
5
|
+
# lsattr is intended to directly delegate to Facter::Util::Resolution.exec in
|
6
|
+
# an effort to make the processorX facts easier to test. See also the
|
7
|
+
# {lsdev} method.
|
8
|
+
def self.lsattr(command="lsattr -El proc0 -a type")
|
9
|
+
Facter::Util::Resolution.exec(command)
|
10
|
+
end
|
11
|
+
|
12
|
+
##
|
13
|
+
# kernel_fact_value is intended to directly delegate to Facter.value(:kernel)
|
14
|
+
# to make it easier to stub the kernel fact without affecting the entire
|
15
|
+
# system.
|
16
|
+
def self.kernel_fact_value
|
17
|
+
Facter.value(:kernel)
|
18
|
+
end
|
19
|
+
end
|
@@ -21,7 +21,7 @@ class Facter::Util::Collection
|
|
21
21
|
# Add a resolution mechanism for a named fact. This does not distinguish
|
22
22
|
# between adding a new fact and adding a new way to resolve a fact.
|
23
23
|
def add(name, options = {}, &block)
|
24
|
-
name =
|
24
|
+
name = canonicalize(name)
|
25
25
|
|
26
26
|
unless fact = @facts[name]
|
27
27
|
fact = Facter::Util::Fact.new(name)
|
@@ -78,7 +78,7 @@ class Facter::Util::Collection
|
|
78
78
|
|
79
79
|
# Return a fact by name.
|
80
80
|
def fact(name)
|
81
|
-
name =
|
81
|
+
name = canonicalize(name)
|
82
82
|
|
83
83
|
# Try to load the fact if necessary
|
84
84
|
load(name) unless @facts[name]
|
@@ -96,6 +96,7 @@ class Facter::Util::Collection
|
|
96
96
|
# Flush all cached values.
|
97
97
|
def flush
|
98
98
|
@facts.each { |name, fact| fact.flush }
|
99
|
+
@external_facts_loaded = nil
|
99
100
|
end
|
100
101
|
|
101
102
|
# Return a list of all of the facts.
|
@@ -106,13 +107,13 @@ class Facter::Util::Collection
|
|
106
107
|
|
107
108
|
def load(name)
|
108
109
|
internal_loader.load(name)
|
109
|
-
|
110
|
+
load_external_facts
|
110
111
|
end
|
111
112
|
|
112
113
|
# Load all known facts.
|
113
114
|
def load_all
|
114
115
|
internal_loader.load_all
|
115
|
-
|
116
|
+
load_external_facts
|
116
117
|
end
|
117
118
|
|
118
119
|
def internal_loader
|
@@ -143,9 +144,14 @@ class Facter::Util::Collection
|
|
143
144
|
|
144
145
|
private
|
145
146
|
|
146
|
-
|
147
|
-
# every time.
|
148
|
-
def canonize(name)
|
147
|
+
def canonicalize(name)
|
149
148
|
name.to_s.downcase.to_sym
|
150
149
|
end
|
150
|
+
|
151
|
+
def load_external_facts
|
152
|
+
if ! @external_facts_loaded
|
153
|
+
@external_facts_loaded = true
|
154
|
+
external_loader.load(self)
|
155
|
+
end
|
156
|
+
end
|
151
157
|
end
|
data/lib/facter/util/config.rb
CHANGED
@@ -30,16 +30,22 @@ module Facter::Util::Config
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.external_facts_dirs
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
if Facter::Util::Root.root?
|
34
|
+
windows_dir = windows_data_dir
|
35
|
+
if windows_dir.nil? then
|
36
|
+
["/etc/facter/facts.d", "/etc/puppetlabs/facter/facts.d"]
|
37
|
+
else
|
38
|
+
[File.join(windows_dir, 'PuppetLabs', 'facter', 'facts.d')]
|
39
|
+
end
|
36
40
|
else
|
37
|
-
[File.join(
|
41
|
+
[File.expand_path(File.join("~", ".facter", "facts.d"))]
|
38
42
|
end
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
42
46
|
if Facter::Util::Config.is_windows?
|
43
|
-
require 'rubygems'
|
44
47
|
require 'win32/dir'
|
48
|
+
require 'facter/util/windows_root'
|
49
|
+
else
|
50
|
+
require 'facter/util/unix_root'
|
45
51
|
end
|
@@ -43,8 +43,8 @@ class Facter::Util::IP::Windows
|
|
43
43
|
interface_names = []
|
44
44
|
|
45
45
|
network_adapter_configurations.map do |nic|
|
46
|
-
Facter::Util::WMI.execquery("SELECT * FROM Win32_NetworkAdapter WHERE Index = #{nic.Index}").each do |nic|
|
47
|
-
interface_names << nic.NetConnectionId
|
46
|
+
Facter::Util::WMI.execquery("SELECT * FROM Win32_NetworkAdapter WHERE Index = #{nic.Index} AND NetEnabled = TRUE").each do |nic|
|
47
|
+
interface_names << nic.NetConnectionId unless nic.NetConnectionId.nil? or nic.NetConnectionId.empty?
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
data/lib/facter/util/loader.rb
CHANGED
@@ -97,7 +97,7 @@ class Facter::Util::Loader
|
|
97
97
|
# Don't store the path if the file can't be loaded
|
98
98
|
# in case it's loadable later on.
|
99
99
|
@loaded.delete(file)
|
100
|
-
warn "Error loading fact #{file} #{detail}"
|
100
|
+
Facter.warn "Error loading fact #{file} #{detail}"
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
data/lib/facter/util/memory.rb
CHANGED
@@ -67,6 +67,14 @@ module Facter::Memory
|
|
67
67
|
freemem = ( memfree + memspecfree ) * pagesize
|
68
68
|
end
|
69
69
|
|
70
|
+
# on AIX use svmon to get the free memory:
|
71
|
+
# it's the third value on the line starting with memory
|
72
|
+
# svmon can be run by non root users
|
73
|
+
def self.svmon_aix_find_free_memory()
|
74
|
+
Facter::Util::Resolution.exec("/usr/bin/svmon -O unit=KB") =~ /^memory\s+\d+\s+\d+\s+(\d+)\s+/
|
75
|
+
$1
|
76
|
+
end
|
77
|
+
|
70
78
|
def self.mem_free(kernel = Facter.value(:kernel))
|
71
79
|
output = mem_free_info(kernel)
|
72
80
|
scale_mem_free_value output, kernel
|
@@ -80,12 +88,14 @@ module Facter::Memory
|
|
80
88
|
vmstat_find_free_memory(["-H"])
|
81
89
|
when /Darwin/i
|
82
90
|
vmstat_darwin_find_free_memory()
|
91
|
+
when /AIX/i
|
92
|
+
svmon_aix_find_free_memory()
|
83
93
|
end
|
84
94
|
end
|
85
95
|
|
86
96
|
def self.scale_mem_free_value (value, kernel)
|
87
97
|
case kernel
|
88
|
-
when /OpenBSD/i, /FreeBSD/i, /SunOS/i, /Dragonfly/i
|
98
|
+
when /OpenBSD/i, /FreeBSD/i, /SunOS/i, /Dragonfly/i, /AIX/i
|
89
99
|
value.to_f / 1024.0
|
90
100
|
when /Darwin/i
|
91
101
|
value.to_f / 1024.0 / 1024.0
|
@@ -109,6 +119,10 @@ module Facter::Memory
|
|
109
119
|
Facter::Util::Resolution.exec("sysctl -n hw.memsize")
|
110
120
|
when /Dragonfly/i
|
111
121
|
Facter::Util::Resolution.exec("sysctl -n hw.physmem")
|
122
|
+
when /AIX/i
|
123
|
+
if Facter::Util::Resolution.exec("/usr/bin/svmon -O unit=KB") =~ /^memory\s+(\d+)\s+/
|
124
|
+
$1
|
125
|
+
end
|
112
126
|
end
|
113
127
|
end
|
114
128
|
|
@@ -116,6 +130,8 @@ module Facter::Memory
|
|
116
130
|
case kernel
|
117
131
|
when /OpenBSD/i, /FreeBSD/i, /Darwin/i, /Dragonfly/i
|
118
132
|
value.to_f / 1024.0 / 1024.0
|
133
|
+
when /AIX/i
|
134
|
+
value.to_f / 1024.0
|
119
135
|
else
|
120
136
|
value.to_f
|
121
137
|
end
|
@@ -134,7 +150,7 @@ module Facter::Memory
|
|
134
150
|
def self.swap_info(kernel = Facter.value(:kernel))
|
135
151
|
case kernel
|
136
152
|
when /AIX/i
|
137
|
-
(Facter.value(:id) == "root") ? Facter::Util::Resolution.exec('swap -l') : nil
|
153
|
+
(Facter.value(:id) == "root") ? Facter::Util::Resolution.exec('swap -l 2>/dev/null') : nil
|
138
154
|
when /OpenBSD/i
|
139
155
|
Facter::Util::Resolution.exec('swapctl -s')
|
140
156
|
when /FreeBSD/i
|
@@ -142,7 +158,7 @@ module Facter::Memory
|
|
142
158
|
when /Darwin/i
|
143
159
|
Facter::Util::Resolution.exec('sysctl vm.swapusage')
|
144
160
|
when /SunOS/i
|
145
|
-
Facter::Util::Resolution.exec('/usr/sbin/swap -l')
|
161
|
+
Facter::Util::Resolution.exec('/usr/sbin/swap -l 2>/dev/null')
|
146
162
|
end
|
147
163
|
end
|
148
164
|
|