prometheus-node-exporter-lua: add openwrt exporter

adds openwrt specific information about the device.
include DISTRIB_{ID, RELEASE, REVISION}, board_name and model

Example output:

    # TYPE node_openwrt_info gauge
    node_openwrt_info{revision="55a0636",model="QEMU Standard PC (i440FX + PIIX, 1996)",id="LiMe",board_name="qemu-standard-pc-i440fx-piix-1996",release="snapshot"} 1
    node_scrape_collector_duration_seconds{collector="openwrt"} 3.814697265625e-05
    node_scrape_collector_success{collector="openwrt"} 1

Signed-off-by: Paul Spooren <spooren@informatik.uni-leipzig.de>
This commit is contained in:
Paul Spooren
2018-05-05 21:10:45 +09:00
parent b0f5972a16
commit 053487cca7
2 changed files with 36 additions and 1 deletions
@@ -0,0 +1,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 }