summaryrefslogtreecommitdiff
path: root/utils/prometheus-node-exporter-lua/files
diff options
context:
space:
mode:
authorMartin Weinelt <hexa@darmstadt.ccc.de>2021-07-24 17:42:25 +0200
committerMartin Weinelt <hexa@darmstadt.ccc.de>2021-07-24 17:44:14 +0200
commit2849ec248d0bcdce700abab9062f74cefccadee4 (patch)
tree5e47cb50c71e62ccc920c3185a26bc9e3870dc69 /utils/prometheus-node-exporter-lua/files
parent1614cdde0a452d002fd90d8496f8a22be9229389 (diff)
prometheus-node-exporter-lua: fix bss identifier in hostapd_stations
We previously did not identify the correct BSS from the output of `hostapd_cli -i <phy> status`, because when asked for a vif it will always respond with information relevant to the whole phy. The per vif settings will use an iterator and we now try to detect the correct BSS from that output. Signed-off-by: Martin Weinelt <hexa@darmstadt.ccc.de>
Diffstat (limited to 'utils/prometheus-node-exporter-lua/files')
-rw-r--r--utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/hostapd_stations.lua20
1 files changed, 13 insertions, 7 deletions
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 a3e6c331a..a176b02e8 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
@@ -16,23 +16,29 @@ local function get_wifi_interface_labels()
handle:close()
local hostapd = {}
+ local bss_idx = -1
for line in hostapd_status:gmatch("[^\r\n]+") do
local name, value = string.match(line, "(.+)=(.+)")
- if name == "phy" then
- hostapd["vif"] = value
elseif name == "freq" then
hostapd["freq"] = value
elseif name == "channel" then
hostapd["channel"] = value
- elseif name == "bssid[0]" then
- hostapd["bssid"] = value
- elseif name == "ssid[0]" then
- hostapd["ssid"] = 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
+ bss_idx = tonumber(string.match(name, "bss%[(%d)%]"))
+ end
+ elseif bss_idx >= 0 then
+ if name == "bssid[" .. bss_idx .. "]" then
+ hostapd["bssid"] = value
+ elseif name == "ssid[" .. bss_idx .. "]" then
+ hostapd["ssid"] = value
+ end
end
end
local labels = {
- vif = hostapd['vif'],
+ vif = cfg['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