prometheus-node-exporter: fix ubus stations
Not every radio has also ubus support. Only query radios with ubus functions. Signed-off-by: Nick Hainke <vincent@systemli.org> [fixup, call ubus.connect() once per scrape] Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
This commit is contained in:
parent
bdd8ab6faf
commit
0a07237514
2 changed files with 11 additions and 10 deletions
|
@ -4,7 +4,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=prometheus-node-exporter-lua
|
PKG_NAME:=prometheus-node-exporter-lua
|
||||||
PKG_VERSION:=2022.04.23
|
PKG_VERSION:=2022.04.30
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
PKG_MAINTAINER:=Etienne CHAMPETIER <champetier.etienne@gmail.com>
|
PKG_MAINTAINER:=Etienne CHAMPETIER <champetier.etienne@gmail.com>
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
local ubus = require "ubus"
|
local ubus = require "ubus"
|
||||||
local bit = require "bit"
|
local bit = require "bit"
|
||||||
|
|
||||||
local function get_wifi_interfaces() -- based on hostapd_stations.lua
|
local function get_wifi_hostapd_interfaces(u)
|
||||||
local u = ubus.connect()
|
local ubuslist = u:objects()
|
||||||
local status = u:call("network.wireless", "status", {})
|
|
||||||
local interfaces = {}
|
local interfaces = {}
|
||||||
|
|
||||||
for _, dev_table in pairs(status) do
|
for _,net in ipairs(ubuslist) do
|
||||||
for _, intf in ipairs(dev_table['interfaces']) do
|
if net.find(net,"hostapd.") then
|
||||||
table.insert(interfaces, intf['ifname'])
|
table.insert(interfaces, net)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -16,6 +15,7 @@ local function get_wifi_interfaces() -- based on hostapd_stations.lua
|
||||||
end
|
end
|
||||||
|
|
||||||
local function scrape()
|
local function scrape()
|
||||||
|
local u = ubus.connect()
|
||||||
local metric_hostapd_ubus_station_rrm_caps_link_measurement =
|
local metric_hostapd_ubus_station_rrm_caps_link_measurement =
|
||||||
metric("hostapd_ubus_station_rrm_caps_link_measurement", "gauge")
|
metric("hostapd_ubus_station_rrm_caps_link_measurement", "gauge")
|
||||||
local metric_hostapd_ubus_station_rrm_caps_neighbor_report =
|
local metric_hostapd_ubus_station_rrm_caps_neighbor_report =
|
||||||
|
@ -55,14 +55,15 @@ local function scrape()
|
||||||
metric_hostapd_ubus_station_rrm_caps_ftm_range_report(label_station, rrm_caps_ftm_range_report)
|
metric_hostapd_ubus_station_rrm_caps_ftm_range_report(label_station, rrm_caps_ftm_range_report)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, ifname in ipairs(get_wifi_interfaces()) do
|
for _, hostapd_int in ipairs(get_wifi_hostapd_interfaces(u)) do
|
||||||
local u = ubus.connect()
|
local clients_call = u:call(hostapd_int, "get_clients", {})
|
||||||
local clients_call = u:call("hostapd." .. ifname, "get_clients", {})
|
local ifname = hostapd_int:gsub("hostapd.", "")
|
||||||
|
|
||||||
for client, client_table in pairs(clients_call['clients']) do
|
for client, client_table in pairs(clients_call['clients']) do
|
||||||
evaluate_metrics(ifname, clients_call['freq'], client, client_table)
|
evaluate_metrics(ifname, clients_call['freq'], client, client_table)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
u:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
return { scrape = scrape }
|
return { scrape = scrape }
|
||||||
|
|
Loading…
Reference in a new issue