Browse Source

Merge pull request #9739 from champtar/master

prometheus-node-exporter-lua: add target & system to OpenWrt collector
lilik-openwrt-22.03
Etienne Champetier 5 years ago
committed by GitHub
parent
commit
3a80fa9cb8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 16 deletions
  1. +2
    -2
      utils/prometheus-node-exporter-lua/Makefile
  2. +14
    -14
      utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/openwrt.lua

+ 2
- 2
utils/prometheus-node-exporter-lua/Makefile View File

@ -4,7 +4,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=prometheus-node-exporter-lua
PKG_VERSION:=2019.04.12
PKG_VERSION:=2019.08.14
PKG_RELEASE:=1
PKG_MAINTAINER:=Etienne CHAMPETIER <champetier.etienne@gmail.com>
@ -79,7 +79,7 @@ endef
define Package/prometheus-node-exporter-lua-openwrt
$(call Package/prometheus-node-exporter-lua/Default)
TITLE+= (openwrt collector)
DEPENDS:=prometheus-node-exporter-lua
DEPENDS:=prometheus-node-exporter-lua +libubus-lua
endef
define Package/prometheus-node-exporter-lua-ltq-dsl


+ 14
- 14
utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/openwrt.lua View File

@ -1,20 +1,20 @@
local ubus = require "ubus"
local u = ubus.connect()
local b = u:call("system", "board", {})
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)
board_name = b.board_name,
id = b.release.distribution,
model = b.model,
release = b.release.version,
revision = b.release.revision,
system = b.system,
target = b.release.target
}
for k, v in string.gmatch(get_contents("/etc/openwrt_release"), "(DISTRIB_%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
b = nil
u = nil
ubus = nil
local function scrape()
metric("node_openwrt_info", "gauge", labels, 1)


Loading…
Cancel
Save