~ubuntu-branches/ubuntu/trusty/facter/trusty

« back to all changes in this revision

Viewing changes to lib/facter/memory.rb

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Palmer
  • Date: 2006-10-31 06:24:59 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061031062459-swxk2h8r33lj8r1f
Tags: 1.3.5-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    def self.meminfo_number(tag)
23
23
        memsize = ""
24
24
        Thread::exclusive do
 
25
            size, scale = [0, ""]
25
26
            File.readlines("/proc/meminfo").each do |l|
26
 
                if l =~ /^#{tag}:\s+(\d+)\s+(\S+)/
27
 
                    memsize = scale_number($1.to_f, $2)
 
27
                size, scale = [$1.to_f, $2] if l =~ /^#{tag}:\s+(\d+)\s+(\S+)/
 
28
                # MemoryFree == memfree + cached + buffers
 
29
                #  (assume scales are all the same as memfree)
 
30
                if tag == "MemFree" &&
 
31
                    l =~ /^(?:Buffers|Cached):\s+(\d+)\s+(?:\S+)/
 
32
                    size += $1.to_f
28
33
                end
29
34
            end
 
35
            memsize = scale_number(size, scale)
30
36
        end
31
37
            
32
38
        memsize