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" Metriks.histogram("os.mem:unused").update(value) apps -= value when "Buffers" Metriks.histogram("os.mem:buffers").update(value) apps -= value when "Cached" Metriks.histogram("os.mem:cache").update(value) apps -= value when "SwapCached" Metriks.histogram("os.mem:swap_cache").update(value) apps -= value when "Slab" Metriks.histogram("os.mem:slab_cache").update(value) apps -= value when "PageTables" Metriks.histogram("os.mem:page_tables").update(value) apps -= value when "Mapped" Metriks.histogram("os.mem:mapped").update(value) end end Metriks.histogram("os.mem:apps").update(apps) end end