aboutsummaryrefslogtreecommitdiff
path: root/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/openwrt.lua
blob: 2f5030d7ad0fbd5d3ec405d6a499e43d6e80237e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
local labels = {
    id = "",
    release = "",
    revision = "",
    model = string.sub(get_contents("/tmp/sysinfo/model"), 1, -2),
    board_name = string.sub(get_contents("/tmp/sysinfo/board_name"), 1, -2)
}

for k, v in string.gmatch(get_contents("/etc/openwrt_release"), "(DISTRIB_%w+)='(%w+)'\n") do
    if k == "DISTRIB_ID" then
        labels["id"] = v
    elseif k == "DISTRIB_RELEASE" then
        labels["release"] = v
    elseif k == "DISTRIB_REVISION" then
        labels["revision"] = v
    end
end

local function scrape()
    metric("node_openwrt_info", "gauge", labels, 1)
end

return { scrape = scrape }