Sha256: ac00f8c6b819f19f2d47907e41c7219ba4a37b2c86c71a3fe58ffcd2e1e5db96

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

# memory.rb
# Additional Facts for memory/swap usage
#
# Copyright (C) 2006 Mooter Media Ltd
# Author: Matthew Palmer <matt@solutionsfirst.com.au>
#
#
require 'facter/util/memory'

{:MemorySize => "MemTotal",
 :MemoryFree => "MemFree",
 :SwapSize   => "SwapTotal",
 :SwapFree   => "SwapFree"}.each do |fact, name|
    Facter.add(fact) do
        confine :kernel => :linux
        setcode do
            Facter::Memory.meminfo_number(name)
        end
    end
end

if Facter.value(:kernel) == "AIX"
    swap = Facter::Util::Resolution.exec('swap -l')
    swapfree, swaptotal = 0, 0
    swap.each do |dev|
        if dev =~ /^\/\S+\s.*\s+(\S+)MB\s+(\S+)MB/
            swaptotal += $1.to_i
            swapfree  += $2.to_i
        end
    end

    Facter.add("SwapSize") do
        confine :kernel => :aix
        setcode do
            Facter::Memory.scale_number(swaptotal.to_f,"MB")
        end
    end

    Facter.add("SwapFree") do
        confine :kernel => :aix
        setcode do
            Facter::Memory.scale_number(swapfree.to_f,"MB")
        end
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
facter-1.5 lib/facter/memory.rb
facter-1.5.2 lib/facter/memory.rb
facter-1.5.3 lib/facter/memory.rb
facter-1.5.4 lib/facter/memory.rb