From a45c702baa1c5e913ac6561ef0e0465b8bd780ce Mon Sep 17 00:00:00 2001 From: Alex Tomlins Date: Sun, 7 Apr 2019 14:08:31 +0100 Subject: [PATCH 1/3] prometheus-node-exporter-lua: wifi packets should be a counter These output a count of the number of packets transmitted/received, so should be tracked as a counter. As it stands, promtool is warning that these shouldn't be named ending _total if they're a gauge. Signed-off-by: Alex Tomlins --- .../files/usr/lib/lua/prometheus-collectors/wifi_stations.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 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 19b5b1eab..d9095a969 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 @@ -3,8 +3,8 @@ local iwinfo = require "iwinfo" local function scrape() local metric_wifi_station_signal = metric("wifi_station_signal_dbm","gauge") - local metric_wifi_station_tx_packets = metric("wifi_station_tx_packets_total","gauge") - local metric_wifi_station_rx_packets = metric("wifi_station_rx_packets_total","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") local u = ubus.connect() local status = u:call("network.wireless", "status", {}) From 1237e196b47dbbd7cac7cf7cabe4b8c86e09e0da Mon Sep 17 00:00:00 2001 From: Alex Tomlins Date: Sun, 7 Apr 2019 14:01:12 +0100 Subject: [PATCH 2/3] 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 --- .../files/usr/lib/lua/prometheus-collectors/wifi_stations.lua | 4 ++++ 1 file changed, 4 insertions(+) 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 From 4b6f76bfac7bd1969c8ca8829a7fe8f9fed43cd0 Mon Sep 17 00:00:00 2001 From: Alex Tomlins Date: Mon, 8 Apr 2019 19:52:32 +0100 Subject: [PATCH 3/3] prometheus-node-exporter-lua: Bump PKG_RELEASE Signed-off-by: Alex Tomlins --- utils/prometheus-node-exporter-lua/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/prometheus-node-exporter-lua/Makefile b/utils/prometheus-node-exporter-lua/Makefile index 18638b39e..d00bc4686 100644 --- a/utils/prometheus-node-exporter-lua/Makefile +++ b/utils/prometheus-node-exporter-lua/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=prometheus-node-exporter-lua PKG_VERSION:=2018.12.30 -PKG_RELEASE:=5 +PKG_RELEASE:=6 PKG_MAINTAINER:=Etienne CHAMPETIER PKG_LICENSE:=Apache-2.0