From 1930d39a15113a8ede7d2794e394678e87697f5d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bal=C3=A1zs=20Urb=C3=A1n?= Date: Sun, 17 Mar 2024 19:59:20 +0100 Subject: [PATCH] prometheus-node-exporter-lua-hostapd_stations: fix not reporting metrics MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - fix incorrect interface name mapping in hostapd_stations exporter Signed-off-by: Balázs Urbán Signed-off-by: Etienne Champetier --- utils/prometheus-node-exporter-lua/Makefile | 2 +- .../lua/prometheus-collectors/hostapd_stations.lua | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/utils/prometheus-node-exporter-lua/Makefile b/utils/prometheus-node-exporter-lua/Makefile index 43ba4c6e9c..6c0d1a949e 100644 --- a/utils/prometheus-node-exporter-lua/Makefile +++ b/utils/prometheus-node-exporter-lua/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=prometheus-node-exporter-lua PKG_VERSION:=2024.06.02 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_MAINTAINER:=Etienne CHAMPETIER PKG_LICENSE:=Apache-2.0 diff --git a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/hostapd_stations.lua b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/hostapd_stations.lua index 2b97c70523..86b406c8a0 100644 --- a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/hostapd_stations.lua +++ b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/hostapd_stations.lua @@ -31,12 +31,10 @@ local function get_wifi_interface_labels() for _, dev_table in pairs(status) do for _, intf in ipairs(dev_table['interfaces']) do - local cfg = intf['config'] - - if is_ubus_interface(ubus_interfaces, cfg['ifname']) then + if is_ubus_interface(ubus_interfaces, intf['ifname']) then -- Migrate this to ubus interface once it exposes all interesting labels - local handle = io.popen("hostapd_cli -i " .. cfg['ifname'] .." status") + local handle = io.popen("hostapd_cli -i " .. intf['ifname'] .." status") local hostapd_status = handle:read("*a") handle:close() @@ -50,7 +48,7 @@ local function get_wifi_interface_labels() hostapd["channel"] = value -- hostapd gives us all bss on the relevant phy, find the one we're interested in elseif string.match(name, "bss%[%d%]") then - if value == cfg['ifname'] then + if value == intf['ifname'] then bss_idx = tonumber(string.match(name, "bss%[(%d)%]")) end elseif bss_idx >= 0 then @@ -63,10 +61,10 @@ local function get_wifi_interface_labels() end local labels = { - vif = cfg['ifname'], + vif = intf['ifname'], ssid = hostapd['ssid'], bssid = hostapd['bssid'], - encryption = cfg['encryption'], -- In a mixed scenario it would be good to know if A or B was used + encryption = intf['config']['encryption'], -- In a mixed scenario it would be good to know if A or B was used frequency = hostapd['freq'], channel = hostapd['channel'], } -- 2.30.2