Report abuse

#
# Output the amount of RAM in Megs on linux.

require 'facter'

Facter.add("ram") do

  confine :kernel => :Linux

  ram = 0

  # Steal linux's meminfo
  File.open( "/proc/meminfo" , 'r' ) do |f|
    f.grep( /^MemTotal:/ ) { |mem|
      ram = mem.split( / +/ )[1].to_i / 1024 
    }
  end

  # http://projects.reductivelabs.com/issues/2455 weird.
  setcode do
    ram
  end

end