From c8760b4ecfa9d2a2d4ed07f5501329f411bf36ba Mon Sep 17 00:00:00 2001 From: Etienne Champetier Date: Sun, 24 May 2026 18:49:15 -0400 Subject: [PATCH] prometheus-node-exporter-lua: fixup uci_dhcp_host Handle cases where 'mac' is missing (nil), a single string, or an array (table). Additionally, add support for the 'duid' field. Signed-off-by: Etienne Champetier --- utils/prometheus-node-exporter-lua/Makefile | 2 +- .../lib/lua/prometheus-collectors/uci_dhcp_host.lua | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/utils/prometheus-node-exporter-lua/Makefile b/utils/prometheus-node-exporter-lua/Makefile index c5f0390d5d..878f5ce41d 100644 --- a/utils/prometheus-node-exporter-lua/Makefile +++ b/utils/prometheus-node-exporter-lua/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=prometheus-node-exporter-lua -PKG_VERSION:=2026.05.07 +PKG_VERSION:=2026.05.08 PKG_RELEASE:=1 PKG_MAINTAINER:=Etienne CHAMPETIER diff --git a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/uci_dhcp_host.lua b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/uci_dhcp_host.lua index 9509625999..2c16fc3c83 100644 --- a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/uci_dhcp_host.lua +++ b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/uci_dhcp_host.lua @@ -5,8 +5,16 @@ local function scrape() local metric_uci_host = metric("uci_dhcp_host", "gauge") curs:foreach("dhcp", "host", function(s) - if s[".type"] == "host" then - labels = {name=s["name"], mac=string.upper(s["mac"]), dns=s["dns"], ip=s["ip"]} + local labels = {name=s["name"], dns=s["dns"], ip=s["ip"], duid=s["duid"]} + + if s["mac"] == nil then + metric_uci_host(labels, 1) + return + end + + local macs = type(s["mac"]) == "table" and s["mac"] or {s["mac"]} + for _, mac in ipairs(macs) do + labels["mac"] = string.upper(mac) metric_uci_host(labels, 1) end end)