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 <szalab9@gmail.com>
Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
This commit is contained in:
Balázs Urbán
2024-03-17 19:59:20 +01:00
committed by Etienne Champetier
parent fe489585c2
commit 1930d39a15
2 changed files with 6 additions and 8 deletions

View File

@@ -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 <champetier.etienne@gmail.com>
PKG_LICENSE:=Apache-2.0

View File

@@ -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'],
}