summaryrefslogtreecommitdiffstats
path: root/lib/facter/memory.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/facter/memory.rb')
-rw-r--r--lib/facter/memory.rb53
1 files changed, 35 insertions, 18 deletions
diff --git a/lib/facter/memory.rb b/lib/facter/memory.rb
index 9dd2e29..992f2ad 100644
--- a/lib/facter/memory.rb
+++ b/lib/facter/memory.rb
@@ -1,3 +1,20 @@
+# Fact: memory
+#
+# Purpose: Return information about memory and swap usage.
+#
+# Resolution:
+# On Linuxes, uses Facter::Memory.meminfo_number from
+# 'facter/util/memory.rb'
+# On AIX, parses "swap -l" for swap values only.
+# On OpenBSD, it parses "swapctl -l" for swap values, vmstat via a module for
+# free memory, and "sysctl hw.physmem" for maximum memory.
+# On Solaris, use "swap -l" for swap values, and parsing prtconf for maximum
+# memory, and again, the vmstat module for free memory.
+#
+# Caveats:
+# Some BSD platforms aren't covered at all. AIX is missing memory values.
+#
+
# memory.rb
# Additional Facts for memory/swap usage
#
@@ -23,30 +40,30 @@ end
Facter.add("SwapSize") do
confine :kernel => :Darwin
setcode do
- swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
- swaptotal = 0
- if swap =~ /total = (\S+)/ then swaptotal = $1; end
- swaptotal
+ swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
+ swaptotal = 0
+ if swap =~ /total = (\S+)/ then swaptotal = $1; end
+ swaptotal
end
end
Facter.add("SwapFree") do
confine :kernel => :Darwin
setcode do
- swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
- swapfree = 0
- if swap =~ /free = (\S+)/ then swapfree = $1; end
- swapfree
+ swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
+ swapfree = 0
+ if swap =~ /free = (\S+)/ then swapfree = $1; end
+ swapfree
end
end
Facter.add("SwapEncrypted") do
confine :kernel => :Darwin
setcode do
- swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
- encrypted = false
- if swap =~ /\(encrypted\)/ then encrypted = true; end
- encrypted
+ swap = Facter::Util::Resolution.exec('sysctl vm.swapusage')
+ encrypted = false
+ if swap =~ /\(encrypted\)/ then encrypted = true; end
+ encrypted
end
end
@@ -57,9 +74,9 @@ if Facter.value(:kernel) == "AIX" and Facter.value(:id) == "root"
if dev =~ /^\/\S+\s.*\s+(\S+)MB\s+(\S+)MB/
swaptotal += $1.to_i
swapfree += $2.to_i
- end
- end
-
+ end
+ end
+
Facter.add("SwapSize") do
confine :kernel => :aix
setcode do
@@ -154,9 +171,9 @@ if Facter.value(:kernel) == "SunOS"
if dev =~ /^\/\S+\s.*\s+(\d+)\s+(\d+)$/
swaptotal += $1.to_i / 2
swapfree += $2.to_i / 2
- end
- end
-
+ end
+ end
+
Facter.add("SwapSize") do
confine :kernel => :sunos
setcode do