summaryrefslogtreecommitdiff
path: root/utils/prometheus-node-exporter-lua
diff options
context:
space:
mode:
authorNick Hainke <vincent@systemli.org>2022-04-30 07:31:52 +0200
committerEtienne Champetier <champetier.etienne@gmail.com>2022-05-29 23:04:12 -0400
commit0a07237514467da0767e09cfe317f9649fc7d928 (patch)
treea7f309343e384009203439c6f03ff50dced29fe9 /utils/prometheus-node-exporter-lua
parentbdd8ab6faf1ade127765f2629ffc955595967510 (diff)
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>
Diffstat (limited to 'utils/prometheus-node-exporter-lua')
-rw-r--r--utils/prometheus-node-exporter-lua/Makefile2
-rw-r--r--utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/hostapd_ubus_stations.lua19
2 files changed, 11 insertions, 10 deletions
diff --git a/utils/prometheus-node-exporter-lua/Makefile b/utils/prometheus-node-exporter-lua/Makefile
index b5472c68f..e59413da0 100644
--- a/utils/prometheus-node-exporter-lua/Makefile
+++ b/utils/prometheus-node-exporter-lua/Makefile
@@ -4,7 +4,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=prometheus-node-exporter-lua
-PKG_VERSION:=2022.04.23
+PKG_VERSION:=2022.04.30
PKG_RELEASE:=1
PKG_MAINTAINER:=Etienne CHAMPETIER <champetier.etienne@gmail.com>
diff --git a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/hostapd_ubus_stations.lua b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/hostapd_ubus_stations.lua
index 88a993c54..3ae441474 100644
--- a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/hostapd_ubus_stations.lua
+++ b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/hostapd_ubus_stations.lua
@@ -1,14 +1,13 @@
local ubus = require "ubus"
local bit = require "bit"
-local function get_wifi_interfaces() -- based on hostapd_stations.lua
- local u = ubus.connect()
- local status = u:call("network.wireless", "status", {})
+local function get_wifi_hostapd_interfaces(u)
+ local ubuslist = u:objects()
local interfaces = {}
- for _, dev_table in pairs(status) do
- for _, intf in ipairs(dev_table['interfaces']) do
- table.insert(interfaces, intf['ifname'])
+ for _,net in ipairs(ubuslist) do
+ if net.find(net,"hostapd.") then
+ table.insert(interfaces, net)
end
end
@@ -16,6 +15,7 @@ local function get_wifi_interfaces() -- based on hostapd_stations.lua
end
local function scrape()
+ local u = ubus.connect()
local metric_hostapd_ubus_station_rrm_caps_link_measurement =
metric("hostapd_ubus_station_rrm_caps_link_measurement", "gauge")
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)
end
- for _, ifname in ipairs(get_wifi_interfaces()) do
- local u = ubus.connect()
- local clients_call = u:call("hostapd." .. ifname, "get_clients", {})
+ for _, hostapd_int in ipairs(get_wifi_hostapd_interfaces(u)) do
+ local clients_call = u:call(hostapd_int, "get_clients", {})
+ local ifname = hostapd_int:gsub("hostapd.", "")
for client, client_table in pairs(clients_call['clients']) do
evaluate_metrics(ifname, clients_call['freq'], client, client_table)
end
end
+ u:close()
end
return { scrape = scrape }