Dashboard memory warning

This commit is contained in:
Neil Lalonde
2013-03-22 15:47:25 -04:00
parent 9c38c13ac5
commit aa6e87c5c1
4 changed files with 42 additions and 1 deletions

15
lib/mem_info.rb Normal file
View File

@@ -0,0 +1,15 @@
class MemInfo
# Total memory in kb. Only works on systems with /proc/meminfo.
# Returns nil if it cannot be determined.
def mem_total
@mem_total ||= begin
if s = `grep MemTotal /proc/meminfo`
/(\d+)/.match(s)[0].try(:to_i)
else
nil
end
end
end
end