summaryrefslogtreecommitdiffstats
path: root/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/meminfo.lua
blob: cf836e3e434280ab1430685d4a1f7f49379f28bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
local function scrape()
  for line in io.lines("/proc/meminfo") do
    local name, size, unit = string.match(line, "([^:]+):%s+(%d+)%s?(k?B?)")
    if unit == 'kB' then
      size = size * 1024
    end
    metric("node_memory_"..name:gsub("[):]", ""):gsub("[(]", "_").."_bytes",
        "gauge", nil, size)
  end
end

return { scrape = scrape }