diff options
| author | Adrien Thebo <adrien@puppetlabs.com> | 2011-03-08 12:59:40 -0800 |
|---|---|---|
| committer | Adrien Thebo <adrien@puppetlabs.com> | 2011-03-15 15:39:23 -0700 |
| commit | ffd80ac4e48285121e6557a06172d47d86270a76 (patch) | |
| tree | b74609907ff7da6548a19fd18c07b2624ceb2dd2 /lib/facter | |
| parent | 4a718a7561e6a87c00d333fedecf6097a8060696 (diff) | |
| download | facter-ffd80ac4e48285121e6557a06172d47d86270a76.tar.gz facter-ffd80ac4e48285121e6557a06172d47d86270a76.tar.xz facter-ffd80ac4e48285121e6557a06172d47d86270a76.zip | |
(#5011) Adds swap statistics for OSX
- Added swapfree and swapsize facts
- Tests will now run correctly for osx swap tests
Diffstat (limited to 'lib/facter')
| -rw-r--r-- | lib/facter/memory.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/facter/memory.rb b/lib/facter/memory.rb index 86adc7f..aa67702 100644 --- a/lib/facter/memory.rb +++ b/lib/facter/memory.rb @@ -20,6 +20,36 @@ require 'facter/util/memory' end 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 + 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 + 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 + end +end + if Facter.value(:kernel) == "AIX" and Facter.value(:id) == "root" swap = Facter::Util::Resolution.exec('swap -l') swapfree, swaptotal = 0, 0 |
