mirror of
https://github.com/novatiq/packages.git
synced 2026-04-29 06:58:39 +01:00
prometheus-node-exporter-lua: put wifi collector in 2 separate packages
this allow to remove libubus-lua/libiwinfo-lua dependency from main package this also allow to have different scrape_interval Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com> split stations Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
This commit is contained in:
@@ -7,10 +7,6 @@ local function scrape()
|
||||
local metric_wifi_network_noise = metric("wifi_network_noise","gauge")
|
||||
local metric_wifi_network_signal = metric("wifi_network_signal","gauge")
|
||||
|
||||
local metric_wifi_station_signal = metric("wifi_station_signal","gauge")
|
||||
local metric_wifi_station_tx_packets = metric("wifi_station_tx_packets","gauge")
|
||||
local metric_wifi_station_rx_packets = metric("wifi_station_rx_packets","gauge")
|
||||
|
||||
local u = ubus.connect()
|
||||
local status = u:call("network.wireless", "status", {})
|
||||
|
||||
@@ -40,17 +36,6 @@ local function scrape()
|
||||
metric_wifi_network_noise(labels, iw.noise(ifname) or 0)
|
||||
metric_wifi_network_bitrate(labels, iw.bitrate(ifname) or 0)
|
||||
metric_wifi_network_signal(labels, iw.signal(ifname) or -255)
|
||||
|
||||
local assoclist = iw.assoclist(ifname)
|
||||
for mac, station in pairs(assoclist) do
|
||||
local labels = {
|
||||
ifname = ifname,
|
||||
mac = mac,
|
||||
}
|
||||
metric_wifi_station_signal(labels, station.signal)
|
||||
metric_wifi_station_tx_packets(labels, station.tx_packets)
|
||||
metric_wifi_station_rx_packets(labels, station.rx_packets)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
local ubus = require "ubus"
|
||||
local iwinfo = require "iwinfo"
|
||||
|
||||
local function scrape()
|
||||
local metric_wifi_station_signal = metric("wifi_station_signal","gauge")
|
||||
local metric_wifi_station_tx_packets = metric("wifi_station_tx_packets","gauge")
|
||||
local metric_wifi_station_rx_packets = metric("wifi_station_rx_packets","gauge")
|
||||
|
||||
local u = ubus.connect()
|
||||
local status = u:call("network.wireless", "status", {})
|
||||
|
||||
for dev, dev_table in pairs(status) do
|
||||
for _, intf in ipairs(dev_table['interfaces']) do
|
||||
local ifname = intf['ifname']
|
||||
local iw = iwinfo[iwinfo.type(ifname)]
|
||||
|
||||
local assoclist = iw.assoclist(ifname)
|
||||
for mac, station in pairs(assoclist) do
|
||||
local labels = {
|
||||
ifname = ifname,
|
||||
mac = mac,
|
||||
}
|
||||
metric_wifi_station_signal(labels, station.signal)
|
||||
metric_wifi_station_tx_packets(labels, station.tx_packets)
|
||||
metric_wifi_station_rx_packets(labels, station.rx_packets)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return { scrape = scrape }
|
||||
Reference in New Issue
Block a user