Skip to content

Instantly share code, notes, and snippets.

@sohooo
Forked from ahpook/memorysize_raw.rb
Created February 3, 2012 11:58
Show Gist options
  • Save sohooo/1729834 to your computer and use it in GitHub Desktop.
Save sohooo/1729834 to your computer and use it in GitHub Desktop.
Custom facter fact for raw memorysize.
# for some reason facter takes the raw memorysize and reports it as
# a formatted string, which is useless for calculation
#
Facter.add("memorysize_raw") do
confine :kernel => :linux
setcode do
size = 0
File.readlines("/proc/meminfo").each do |l|
size = $1.to_f if l =~ /^MemTotal:\s+(\d+)/
end
size
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment