Browse Source

Merge pull request #16217 from mweinelt/prometheus-hostapd-stations-ifname-fix

prometheus-node-exporter-lua: fix bss identifier in hostapd_stations
lilik-openwrt-22.03
David Bauer 3 years ago
committed by GitHub
parent
commit
bd08bdea6b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 8 deletions
  1. +1
    -1
      utils/prometheus-node-exporter-lua/Makefile
  2. +13
    -7
      utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/hostapd_stations.lua

+ 1
- 1
utils/prometheus-node-exporter-lua/Makefile View File

@ -4,7 +4,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=prometheus-node-exporter-lua
PKG_VERSION:=2021.07.04
PKG_VERSION:=2021.07.24
PKG_RELEASE:=1
PKG_MAINTAINER:=Etienne CHAMPETIER <champetier.etienne@gmail.com>


+ 13
- 7
utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/hostapd_stations.lua View File

@ -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


Loading…
Cancel
Save