facter 1.6.1 → 1.6.2
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/CHANGELOG +31 -0
- data/Rakefile +41 -36
- data/conf/redhat/facter.spec +11 -4
- data/conf/solaris/pkginfo +1 -1
- data/install.rb +286 -286
- data/lib/facter.rb +211 -211
- data/lib/facter/Cfkey.rb +24 -24
- data/lib/facter/application.rb +1 -0
- data/lib/facter/architecture.rb +21 -29
- data/lib/facter/domain.rb +34 -34
- data/lib/facter/facterversion.rb +1 -1
- data/lib/facter/fqdn.rb +8 -8
- data/lib/facter/hardwareisa.rb +2 -2
- data/lib/facter/hardwaremodel.rb +12 -12
- data/lib/facter/hostname.rb +14 -14
- data/lib/facter/id.rb +3 -3
- data/lib/facter/interfaces.rb +13 -13
- data/lib/facter/ipaddress.rb +101 -101
- data/lib/facter/iphostnumber.rb +12 -12
- data/lib/facter/kernel.rb +7 -7
- data/lib/facter/kernelmajversion.rb +3 -3
- data/lib/facter/kernelrelease.rb +12 -12
- data/lib/facter/kernelversion.rb +5 -5
- data/lib/facter/lsb.rb +14 -14
- data/lib/facter/lsbmajdistrelease.rb +8 -8
- data/lib/facter/macaddress.rb +44 -44
- data/lib/facter/macosx.rb +21 -21
- data/lib/facter/manufacturer.rb +28 -28
- data/lib/facter/memory.rb +143 -115
- data/lib/facter/netmask.rb +4 -4
- data/lib/facter/network.rb +4 -4
- data/lib/facter/operatingsystem.rb +73 -69
- data/lib/facter/operatingsystemrelease.rb +85 -79
- data/lib/facter/osfamily.rb +31 -0
- data/lib/facter/path.rb +3 -3
- data/lib/facter/physicalprocessorcount.rb +8 -0
- data/lib/facter/processor.rb +91 -72
- data/lib/facter/ps.rb +3 -3
- data/lib/facter/puppetversion.rb +7 -7
- data/lib/facter/rubysitedir.rb +5 -5
- data/lib/facter/rubyversion.rb +1 -1
- data/lib/facter/ssh.rb +16 -16
- data/lib/facter/timezone.rb +3 -3
- data/lib/facter/uniqueid.rb +2 -2
- data/lib/facter/util/collection.rb +96 -96
- data/lib/facter/util/confine.rb +30 -30
- data/lib/facter/util/fact.rb +95 -95
- data/lib/facter/util/ip.rb +173 -173
- data/lib/facter/util/loader.rb +88 -88
- data/lib/facter/util/macosx.rb +46 -46
- data/lib/facter/util/manufacturer.rb +78 -78
- data/lib/facter/util/memory.rb +63 -63
- data/lib/facter/util/netmask.rb +34 -34
- data/lib/facter/util/plist.rb +1 -1
- data/lib/facter/util/plist/generator.rb +177 -177
- data/lib/facter/util/plist/parser.rb +166 -166
- data/lib/facter/util/processor.rb +88 -0
- data/lib/facter/util/resolution.rb +154 -154
- data/lib/facter/util/uptime.rb +42 -42
- data/lib/facter/util/values.rb +9 -9
- data/lib/facter/util/virtual.rb +68 -58
- data/lib/facter/util/vlans.rb +17 -17
- data/lib/facter/virtual.rb +105 -110
- data/lib/facter/vlans.rb +6 -6
- data/spec/fixtures/cpuinfo/amd64dual +57 -0
- data/spec/fixtures/cpuinfo/amd64quad +79 -0
- data/spec/fixtures/cpuinfo/amd64solo +23 -0
- data/spec/fixtures/cpuinfo/amd64tri +86 -0
- data/spec/fixtures/cpuinfo/bbg3-armel +12 -0
- data/spec/fixtures/cpuinfo/beaglexm-armel +12 -0
- data/spec/fixtures/cpuinfo/panda-armel +17 -0
- data/spec/fixtures/cpuinfo/ppc64 +19 -0
- data/spec/fixtures/cpuinfo/sparc +10 -0
- data/spec/fixtures/processorcount/solaris-sparc-kstat-cpu-info +1216 -0
- data/spec/fixtures/processorcount/solaris-x86_64-kstat-cpu-info +225 -0
- data/spec/integration/facter_spec.rb +18 -18
- data/spec/spec_helper.rb +10 -1
- data/spec/unit/architecture_spec.rb +54 -0
- data/spec/unit/domain_spec.rb +23 -0
- data/spec/unit/memory_spec.rb +78 -1
- data/spec/unit/physicalprocessorcount_spec.rb +41 -35
- data/spec/unit/processor_spec.rb +183 -2
- data/spec/unit/util/processor_spec.rb +62 -0
- data/spec/unit/util/uptime_spec.rb +4 -4
- data/spec/unit/util/virtual_spec.rb +26 -5
- data/spec/unit/virtual_spec.rb +47 -2
- data/spec/watchr.rb +125 -0
- metadata +20 -4
data/lib/facter/iphostnumber.rb
CHANGED
@@ -10,20 +10,20 @@
|
|
10
10
|
#
|
11
11
|
|
12
12
|
Facter.add(:iphostnumber) do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
confine :kernel => :darwin, :kernelrelease => "R6"
|
14
|
+
setcode do
|
15
|
+
%x{/usr/sbin/scutil --get LocalHostName}
|
16
|
+
end
|
17
17
|
end
|
18
18
|
Facter.add(:iphostnumber) do
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
confine :kernel => :darwin, :kernelrelease => "R6"
|
20
|
+
setcode do
|
21
|
+
ether = nil
|
22
|
+
output = %x{/sbin/ifconfig}
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
output =~ /HWaddr (\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/
|
25
|
+
ether = $1
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
ether
|
28
|
+
end
|
29
29
|
end
|
data/lib/facter/kernel.rb
CHANGED
@@ -10,13 +10,13 @@
|
|
10
10
|
#
|
11
11
|
|
12
12
|
Facter.add(:kernel) do
|
13
|
-
|
14
|
-
|
13
|
+
setcode do
|
14
|
+
require 'facter/util/config'
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
16
|
+
if Facter::Util::Config.is_windows?
|
17
|
+
'windows'
|
18
|
+
else
|
19
|
+
Facter::Util::Resolution.exec("uname -s")
|
21
20
|
end
|
21
|
+
end
|
22
22
|
end
|
data/lib/facter/kernelrelease.rb
CHANGED
@@ -12,23 +12,23 @@
|
|
12
12
|
#
|
13
13
|
|
14
14
|
Facter.add(:kernelrelease) do
|
15
|
-
|
15
|
+
setcode 'uname -r'
|
16
16
|
end
|
17
17
|
|
18
18
|
Facter.add(:kernelrelease) do
|
19
|
-
|
20
|
-
|
19
|
+
confine :kernel => :aix
|
20
|
+
setcode 'oslevel -s'
|
21
21
|
end
|
22
22
|
|
23
23
|
Facter.add(:kernelrelease) do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
version
|
24
|
+
confine :kernel => %{windows}
|
25
|
+
setcode do
|
26
|
+
require 'facter/util/wmi'
|
27
|
+
version = ""
|
28
|
+
Facter::Util::WMI.execquery("SELECT Version from Win32_OperatingSystem").each do |ole|
|
29
|
+
version = "#{ole.Version}"
|
30
|
+
break
|
33
31
|
end
|
32
|
+
version
|
33
|
+
end
|
34
34
|
end
|
data/lib/facter/kernelversion.rb
CHANGED
@@ -11,12 +11,12 @@
|
|
11
11
|
#
|
12
12
|
|
13
13
|
Facter.add("kernelversion") do
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
setcode do
|
15
|
+
Facter['kernelrelease'].value.split('-')[0]
|
16
|
+
end
|
17
17
|
end
|
18
18
|
|
19
19
|
Facter.add("kernelversion") do
|
20
|
-
|
21
|
-
|
20
|
+
confine :kernel => :sunos
|
21
|
+
setcode 'uname -v'
|
22
22
|
end
|
data/lib/facter/lsb.rb
CHANGED
@@ -20,20 +20,20 @@
|
|
20
20
|
"LSBDistDescription" => %r{^Description:\t(.*)$},
|
21
21
|
"LSBDistCodeName" => %r{^Codename:\t(.*)$}
|
22
22
|
}.each do |fact, pattern|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
Facter.add(fact) do
|
24
|
+
confine :kernel => [ :linux, :"gnu/kfreebsd" ]
|
25
|
+
setcode do
|
26
|
+
unless defined?(lsbdata) and defined?(lsbtime) and (Time.now.to_i - lsbtime.to_i < 5)
|
27
|
+
type = nil
|
28
|
+
lsbtime = Time.now
|
29
|
+
lsbdata = Facter::Util::Resolution.exec('lsb_release -a 2>/dev/null')
|
30
|
+
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
32
|
+
if pattern.match(lsbdata)
|
33
|
+
$1
|
34
|
+
else
|
35
|
+
nil
|
36
|
+
end
|
38
37
|
end
|
38
|
+
end
|
39
39
|
end
|
@@ -15,13 +15,13 @@
|
|
15
15
|
require 'facter'
|
16
16
|
|
17
17
|
Facter.add("lsbmajdistrelease") do
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
result
|
18
|
+
confine :operatingsystem => %w{Linux Fedora RedHat CentOS Scientific SLC SuSE SLES Debian Ubuntu Gentoo OEL OracleLinux OVS GNU/kFreeBSD}
|
19
|
+
setcode do
|
20
|
+
if /(\d*)\./i =~ Facter.value(:lsbdistrelease)
|
21
|
+
result=$1
|
22
|
+
else
|
23
|
+
result=Facter.value(:lsbdistrelease)
|
26
24
|
end
|
25
|
+
result
|
26
|
+
end
|
27
27
|
end
|
data/lib/facter/macaddress.rb
CHANGED
@@ -10,69 +10,69 @@
|
|
10
10
|
require 'facter/util/macaddress'
|
11
11
|
|
12
12
|
Facter.add(:macaddress) do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
Facter::Util::Macaddress.standardize(ether[0])
|
13
|
+
confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific SLC SuSE SLES Debian Gentoo Ubuntu OEL OracleLinux OVS GNU/kFreeBSD}
|
14
|
+
setcode do
|
15
|
+
ether = []
|
16
|
+
output = Facter::Util::Resolution.exec("/sbin/ifconfig -a")
|
17
|
+
output.each_line do |s|
|
18
|
+
ether.push($1) if s =~ /(?:ether|HWaddr) (\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/
|
21
19
|
end
|
20
|
+
Facter::Util::Macaddress.standardize(ether[0])
|
21
|
+
end
|
22
22
|
end
|
23
23
|
|
24
24
|
Facter.add(:macaddress) do
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
Facter::Util::Macaddress.standardize(ether[0])
|
25
|
+
confine :operatingsystem => "Solaris"
|
26
|
+
setcode do
|
27
|
+
ether = []
|
28
|
+
output = Facter::Util::Resolution.exec("/usr/bin/netstat -np")
|
29
|
+
output.each_line do |s|
|
30
|
+
ether.push($1) if s =~ /(?:SPLA)\s+(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})/
|
33
31
|
end
|
32
|
+
Facter::Util::Macaddress.standardize(ether[0])
|
33
|
+
end
|
34
34
|
end
|
35
35
|
|
36
36
|
Facter.add(:macaddress) do
|
37
|
-
|
38
|
-
|
37
|
+
confine :operatingsystem => %w{FreeBSD OpenBSD DragonFly}
|
38
|
+
setcode do
|
39
39
|
ether = []
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
Facter::Util::Macaddress.standardize(ether[0])
|
40
|
+
output = Facter::Util::Resolution.exec("/sbin/ifconfig")
|
41
|
+
output.each_line do |s|
|
42
|
+
if s =~ /(?:ether|lladdr)\s+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)/
|
43
|
+
ether.push($1)
|
44
|
+
end
|
47
45
|
end
|
46
|
+
Facter::Util::Macaddress.standardize(ether[0])
|
47
|
+
end
|
48
48
|
end
|
49
49
|
|
50
50
|
Facter.add(:macaddress) do
|
51
|
-
|
52
|
-
|
51
|
+
confine :kernel => :darwin
|
52
|
+
setcode { Facter::Util::Macaddress::Darwin.macaddress }
|
53
53
|
end
|
54
54
|
|
55
55
|
Facter.add(:macaddress) do
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
56
|
+
confine :kernel => %w{AIX}
|
57
|
+
setcode do
|
58
|
+
ether = []
|
59
|
+
ip = nil
|
60
|
+
output = %x{/usr/sbin/ifconfig -a}
|
61
|
+
output.each_line do |str|
|
62
|
+
if str =~ /([a-z]+\d+): flags=/
|
63
|
+
devname = $1
|
64
|
+
unless devname =~ /lo0/
|
65
|
+
output2 = %x{/usr/bin/entstat #{devname}}
|
66
|
+
output2.each_line do |str2|
|
67
|
+
if str2 =~ /^Hardware Address: (\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/
|
68
|
+
ether.push($1)
|
72
69
|
end
|
70
|
+
end
|
73
71
|
end
|
74
|
-
|
72
|
+
end
|
75
73
|
end
|
74
|
+
Facter::Util::Macaddress.standardize(ether[0])
|
75
|
+
end
|
76
76
|
end
|
77
77
|
|
78
78
|
Facter.add(:macaddress) do
|
data/lib/facter/macosx.rb
CHANGED
@@ -27,30 +27,30 @@
|
|
27
27
|
require 'facter/util/macosx'
|
28
28
|
|
29
29
|
if Facter.value(:kernel) == "Darwin"
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
30
|
+
Facter::Util::Macosx.hardware_overview.each do |fact, value|
|
31
|
+
Facter.add("sp_#{fact}") do
|
32
|
+
confine :kernel => :darwin
|
33
|
+
setcode do
|
34
|
+
value.to_s
|
35
|
+
end
|
37
36
|
end
|
37
|
+
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
39
|
+
Facter::Util::Macosx.os_overview.each do |fact, value|
|
40
|
+
Facter.add("sp_#{fact}") do
|
41
|
+
confine :kernel => :darwin
|
42
|
+
setcode do
|
43
|
+
value.to_s
|
44
|
+
end
|
46
45
|
end
|
46
|
+
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
48
|
+
Facter::Util::Macosx.sw_vers.each do |fact, value|
|
49
|
+
Facter.add(fact) do
|
50
|
+
confine :kernel => :darwin
|
51
|
+
setcode do
|
52
|
+
value
|
53
|
+
end
|
55
54
|
end
|
55
|
+
end
|
56
56
|
end
|
data/lib/facter/manufacturer.rb
CHANGED
@@ -19,39 +19,39 @@
|
|
19
19
|
require 'facter/util/manufacturer'
|
20
20
|
|
21
21
|
if Facter.value(:kernel) == "OpenBSD"
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
mfg_keys = {
|
23
|
+
'hw.vendor' => 'manufacturer',
|
24
|
+
'hw.product' => 'productname',
|
25
|
+
'hw.serialno' => 'serialnumber'
|
26
|
+
}
|
27
27
|
|
28
|
-
|
28
|
+
Facter::Manufacturer.sysctl_find_system_info(mfg_keys)
|
29
29
|
elsif Facter.value(:kernel) == "Darwin"
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
mfg_keys = {
|
31
|
+
'hw.model' => 'productname'
|
32
|
+
}
|
33
|
+
Facter::Manufacturer.sysctl_find_system_info(mfg_keys)
|
34
34
|
elsif Facter.value(:kernel) == "SunOS" and Facter.value(:hardwareisa) == "sparc"
|
35
|
-
|
35
|
+
Facter::Manufacturer.prtdiag_sparc_find_system_info()
|
36
36
|
elsif Facter.value(:kernel) == "windows"
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
win32_keys = {
|
38
|
+
'manufacturer' => ['Manufacturer', 'Bios'],
|
39
|
+
'serialNumber' => ['Serialnumber', 'Bios'],
|
40
|
+
'productname' => ['Name', 'ComputerSystemProduct']
|
41
|
+
}
|
42
|
+
Facter::Manufacturer.win32_find_system_info(win32_keys)
|
43
43
|
else
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
44
|
+
query = {
|
45
|
+
'[Ss]ystem [Ii]nformation' => [
|
46
|
+
{ 'Manufacturer:' => 'manufacturer' },
|
47
|
+
{ 'Product(?: Name)?:' => 'productname' },
|
48
|
+
{ 'Serial Number:' => 'serialnumber' }
|
49
|
+
],
|
50
|
+
'(Chassis Information|system enclosure or chassis)' => [
|
51
|
+
{ '(?:Chassis )?Type:' => 'type' }
|
52
|
+
]
|
53
|
+
}
|
54
54
|
|
55
|
-
|
55
|
+
Facter::Manufacturer.dmi_find_system_info(query)
|
56
56
|
end
|
57
57
|
|
data/lib/facter/memory.rb
CHANGED
@@ -29,182 +29,180 @@ require 'facter/util/memory'
|
|
29
29
|
:SwapSize => "SwapTotal",
|
30
30
|
:SwapFree => "SwapFree"
|
31
31
|
}.each do |fact, name|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
32
|
+
Facter.add(fact) do
|
33
|
+
confine :kernel => [ :linux, :"gnu/kfreebsd" ]
|
34
|
+
setcode do
|
35
|
+
Facter::Memory.meminfo_number(name)
|
37
36
|
end
|
37
|
+
end
|
38
38
|
end
|
39
39
|
|
40
40
|
Facter.add("SwapSize") do
|
41
|
-
|
42
|
-
|
41
|
+
confine :kernel => :Darwin
|
42
|
+
setcode do
|
43
43
|
swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
|
44
44
|
swaptotal = 0
|
45
45
|
if swap =~ /total = (\S+)/ then swaptotal = $1; end
|
46
|
-
|
47
|
-
|
46
|
+
swaptotal
|
47
|
+
end
|
48
48
|
end
|
49
49
|
|
50
50
|
Facter.add("SwapFree") do
|
51
|
-
|
52
|
-
|
51
|
+
confine :kernel => :Darwin
|
52
|
+
setcode do
|
53
53
|
swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
|
54
54
|
swapfree = 0
|
55
55
|
if swap =~ /free = (\S+)/ then swapfree = $1; end
|
56
|
-
|
57
|
-
|
56
|
+
swapfree
|
57
|
+
end
|
58
58
|
end
|
59
59
|
|
60
60
|
Facter.add("SwapEncrypted") do
|
61
|
-
|
62
|
-
|
61
|
+
confine :kernel => :Darwin
|
62
|
+
setcode do
|
63
63
|
swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
|
64
64
|
encrypted = false
|
65
65
|
if swap =~ /\(encrypted\)/ then encrypted = true; end
|
66
|
-
|
67
|
-
|
66
|
+
encrypted
|
67
|
+
end
|
68
68
|
end
|
69
69
|
|
70
70
|
if Facter.value(:kernel) == "AIX" and Facter.value(:id) == "root"
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
71
|
+
swap = Facter::Util::Resolution.exec('swap -l')
|
72
|
+
swapfree, swaptotal = 0, 0
|
73
|
+
swap.each_line do |dev|
|
74
|
+
if dev =~ /^\/\S+\s.*\s+(\S+)MB\s+(\S+)MB/
|
75
|
+
swaptotal += $1.to_i
|
76
|
+
swapfree += $2.to_i
|
78
77
|
end
|
78
|
+
end
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
80
|
+
Facter.add("SwapSize") do
|
81
|
+
confine :kernel => :aix
|
82
|
+
setcode do
|
83
|
+
Facter::Memory.scale_number(swaptotal.to_f,"MB")
|
85
84
|
end
|
85
|
+
end
|
86
86
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
87
|
+
Facter.add("SwapFree") do
|
88
|
+
confine :kernel => :aix
|
89
|
+
setcode do
|
90
|
+
Facter::Memory.scale_number(swapfree.to_f,"MB")
|
92
91
|
end
|
92
|
+
end
|
93
93
|
end
|
94
94
|
|
95
95
|
if Facter.value(:kernel) == "OpenBSD"
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end
|
103
|
-
end
|
96
|
+
swap = Facter::Util::Resolution.exec('swapctl -s')
|
97
|
+
swapfree, swaptotal = 0, 0
|
98
|
+
if swap =~ /^total: (\d+)k bytes allocated = \d+k used, (\d+)k available$/
|
99
|
+
swaptotal = $1.to_i
|
100
|
+
swapfree = $2.to_i
|
101
|
+
end
|
104
102
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
end
|
103
|
+
Facter.add("SwapSize") do
|
104
|
+
confine :kernel => :openbsd
|
105
|
+
setcode do
|
106
|
+
Facter::Memory.scale_number(swaptotal.to_f,"kB")
|
110
107
|
end
|
108
|
+
end
|
111
109
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
end
|
110
|
+
Facter.add("SwapFree") do
|
111
|
+
confine :kernel => :openbsd
|
112
|
+
setcode do
|
113
|
+
Facter::Memory.scale_number(swapfree.to_f,"kB")
|
117
114
|
end
|
115
|
+
end
|
118
116
|
|
119
|
-
|
117
|
+
Facter::Memory.vmstat_find_free_memory()
|
120
118
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
end
|
119
|
+
Facter.add("MemoryTotal") do
|
120
|
+
confine :kernel => :openbsd
|
121
|
+
memtotal = Facter::Util::Resolution.exec("sysctl hw.physmem | cut -d'=' -f2")
|
122
|
+
setcode do
|
123
|
+
Facter::Memory.scale_number(memtotal.to_f,"")
|
127
124
|
end
|
125
|
+
end
|
128
126
|
end
|
129
127
|
|
130
128
|
if Facter.value(:kernel) == "Darwin"
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
end
|
129
|
+
swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
|
130
|
+
swapfree, swaptotal = 0, 0
|
131
|
+
unless swap.empty?
|
132
|
+
# Parse the line:
|
133
|
+
# vm.swapusage: total = 128.00M used = 0.37M free = 127.63M (encrypted)
|
134
|
+
if swap =~ /total\s=\s(\S+)\s+used\s=\s(\S+)\s+free\s=\s(\S+)\s/
|
135
|
+
swaptotal += $1.to_i
|
136
|
+
swapfree += $3.to_i
|
140
137
|
end
|
138
|
+
end
|
141
139
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
end
|
140
|
+
Facter.add("SwapSize") do
|
141
|
+
confine :kernel => :Darwin
|
142
|
+
setcode do
|
143
|
+
Facter::Memory.scale_number(swaptotal.to_f,"MB")
|
147
144
|
end
|
145
|
+
end
|
148
146
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
end
|
147
|
+
Facter.add("SwapFree") do
|
148
|
+
confine :kernel => :Darwin
|
149
|
+
setcode do
|
150
|
+
Facter::Memory.scale_number(swapfree.to_f,"MB")
|
154
151
|
end
|
152
|
+
end
|
155
153
|
|
156
|
-
|
154
|
+
Facter::Memory.vmstat_darwin_find_free_memory()
|
157
155
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
end
|
156
|
+
Facter.add("MemoryTotal") do
|
157
|
+
confine :kernel => :Darwin
|
158
|
+
memtotal = Facter::Util::Resolution.exec("sysctl hw.memsize | cut -d':' -f2")
|
159
|
+
setcode do
|
160
|
+
Facter::Memory.scale_number(memtotal.to_f,"")
|
164
161
|
end
|
162
|
+
end
|
165
163
|
end
|
166
164
|
|
167
165
|
if Facter.value(:kernel) == "SunOS"
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
end
|
166
|
+
swap = Facter::Util::Resolution.exec('/usr/sbin/swap -l')
|
167
|
+
swapfree, swaptotal = 0, 0
|
168
|
+
swap.each_line do |dev|
|
169
|
+
if dev =~ /^\/\S+\s.*\s+(\d+)\s+(\d+)$/
|
170
|
+
swaptotal += $1.to_i / 2
|
171
|
+
swapfree += $2.to_i / 2
|
175
172
|
end
|
173
|
+
end
|
176
174
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
end
|
175
|
+
Facter.add("SwapSize") do
|
176
|
+
confine :kernel => :sunos
|
177
|
+
setcode do
|
178
|
+
Facter::Memory.scale_number(swaptotal.to_f,"kB")
|
182
179
|
end
|
180
|
+
end
|
183
181
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
end
|
182
|
+
Facter.add("SwapFree") do
|
183
|
+
confine :kernel => :sunos
|
184
|
+
setcode do
|
185
|
+
Facter::Memory.scale_number(swapfree.to_f,"kB")
|
189
186
|
end
|
187
|
+
end
|
190
188
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
end
|
189
|
+
# Total memory size available from prtconf
|
190
|
+
pconf = Facter::Util::Resolution.exec('/usr/sbin/prtconf 2>/dev/null')
|
191
|
+
phymem = ""
|
192
|
+
pconf.each_line do |line|
|
193
|
+
if line =~ /^Memory size:\s+(\d+) Megabytes/
|
194
|
+
phymem = $1
|
198
195
|
end
|
196
|
+
end
|
199
197
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
end
|
198
|
+
Facter.add("MemorySize") do
|
199
|
+
confine :kernel => :sunos
|
200
|
+
setcode do
|
201
|
+
Facter::Memory.scale_number(phymem.to_f,"MB")
|
205
202
|
end
|
203
|
+
end
|
206
204
|
|
207
|
-
|
205
|
+
Facter::Memory.vmstat_find_free_memory()
|
208
206
|
end
|
209
207
|
|
210
208
|
if Facter.value(:kernel) == "windows"
|
@@ -234,3 +232,33 @@ if Facter.value(:kernel) == "windows"
|
|
234
232
|
end
|
235
233
|
end
|
236
234
|
end
|
235
|
+
|
236
|
+
Facter.add("SwapSize") do
|
237
|
+
confine :kernel => :dragonfly
|
238
|
+
setcode do
|
239
|
+
page_size = Facter::Util::Resolution.exec("/sbin/sysctl -n hw.pagesize").to_f
|
240
|
+
swaptotal = Facter::Util::Resolution.exec("/sbin/sysctl -n vm.swap_size").to_f * page_size
|
241
|
+
Facter::Memory.scale_number(swaptotal.to_f,"")
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
Facter.add("SwapFree") do
|
246
|
+
confine :kernel => :dragonfly
|
247
|
+
setcode do
|
248
|
+
page_size = Facter::Util::Resolution.exec("/sbin/sysctl -n hw.pagesize").to_f
|
249
|
+
swaptotal = Facter::Util::Resolution.exec("/sbin/sysctl -n vm.swap_size").to_f * page_size
|
250
|
+
swap_anon_use = Facter::Util::Resolution.exec("/sbin/sysctl -n vm.swap_anon_use").to_f * page_size
|
251
|
+
swap_cache_use = Facter::Util::Resolution.exec("/sbin/sysctl -n vm.swap_cache_use").to_f * page_size
|
252
|
+
swapfree = swaptotal - swap_anon_use - swap_cache_use
|
253
|
+
Facter::Memory.scale_number(swapfree.to_f,"")
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
Facter.add("MemoryTotal") do
|
258
|
+
confine :kernel => :dragonfly
|
259
|
+
setcode do
|
260
|
+
Facter::Memory.vmstat_find_free_memory()
|
261
|
+
memtotal = Facter::Util::Resolution.exec("sysctl -n hw.physmem")
|
262
|
+
Facter::Memory.scale_number(memtotal.to_f,"")
|
263
|
+
end
|
264
|
+
end
|