diff options
author | Alex Tomlins <alex@tomlins.org.uk> | 2019-04-07 14:01:12 +0100 |
---|---|---|
committer | Alex Tomlins <alex@tomlins.org.uk> | 2019-04-08 19:39:34 +0100 |
commit | 1237e196b47dbbd7cac7cf7cabe4b8c86e09e0da (patch) | |
tree | 9ca34dbf75a8dd9d76aaa45a66021334804ae99a /utils/prometheus-node-exporter-lua/files/usr/lib/lua | |
parent | a45c702baa1c5e913ac6561ef0e0465b8bd780ce (diff) |
prometheus-node-exporter-lua: Add wifi_station_count
To return the number of connected clients.
At present this can be partially inferred by using a count() over one of
the existing metrics, however this doesn't handle the case when there
are no connected clients. When that happens, the count() will return no
data instead of 0.
Signed-off-by: Alex Tomlins <alex@tomlins.org.uk>
Diffstat (limited to 'utils/prometheus-node-exporter-lua/files/usr/lib/lua')
-rw-r--r-- | utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua index d9095a969..25c144f02 100644 --- a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua +++ b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua @@ -2,6 +2,7 @@ local ubus = require "ubus" local iwinfo = require "iwinfo" local function scrape() + local metric_wifi_stations = metric("wifi_stations", "gauge") local metric_wifi_station_signal = metric("wifi_station_signal_dbm","gauge") local metric_wifi_station_tx_packets = metric("wifi_station_tx_packets_total","counter") local metric_wifi_station_rx_packets = metric("wifi_station_rx_packets_total","counter") @@ -13,6 +14,7 @@ local function scrape() for _, intf in ipairs(dev_table['interfaces']) do local ifname = intf['ifname'] local iw = iwinfo[iwinfo.type(ifname)] + local count = 0 local assoclist = iw.assoclist(ifname) for mac, station in pairs(assoclist) do @@ -23,7 +25,9 @@ local function scrape() 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) + count = count + 1 end + metric_wifi_stations({ifname = ifname}, count) end end end |