From: Balázs Urbán Date: Sun, 17 Mar 2024 18:59:20 +0000 (+0100) Subject: prometheus-node-exporter-lua-hostapd_stations: fix not reporting metrics X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=1930d39a15113a8ede7d2794e394678e87697f5d;p=openwrt-packages.git prometheus-node-exporter-lua-hostapd_stations: fix not reporting metrics - fix incorrect interface name mapping in hostapd_stations exporter Signed-off-by: Balázs Urbán Signed-off-by: Etienne Champetier --- diff --git a/utils/prometheus-node-exporter-lua/Makefile b/utils/prometheus-node-exporter-lua/Makefile index 43ba4c6e9..6c0d1a949 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 2b97c7052..86b406c8a 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'], }