-
-
Save sohooo/1729834 to your computer and use it in GitHub Desktop.
Custom facter fact for raw memorysize.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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