collect do next if not File.readable?('/proc/meminfo') # calculate app memory from total apps = 0 File.open('/proc/meminfo') do |file| file.each do |line| key, value, unit = line.chomp.split key.gsub!(/:/, '') value = value.to_i * 1024 case key when "MemTotal" apps = value when "MemFree" sampler.emit(:gauge, "os.mem.unused", value) apps -= value when "Buffers" sampler.emit(:gauge, "os.mem.buffers", value) apps -= value when "Cached" sampler.emit(:gauge, "os.mem.cache", value) apps -= value when "SwapCached" sampler.emit(:gauge, "os.mem.swap_cache", value) apps -= value when "Slab" sampler.emit(:gauge, "os.mem.slab_cache", value) apps -= value when "PageTables" sampler.emit(:gauge, "os.mem.page_tables", value) apps -= value when "Mapped" sampler.emit(:gauge, "os.mem.mapped", value) end end sampler.emit(:gauge, "os.mem.apps", apps) end end