Browse Source

Merge pull request #8625 from alext/wifi_station_count

prometheus-node-exporter-lua: Add wifi_station_count metric
lilik-openwrt-22.03
champtar 6 years ago
committed by GitHub
parent
commit
d8af441a95
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions
  1. +1
    -1
      utils/prometheus-node-exporter-lua/Makefile
  2. +6
    -2
      utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua

+ 1
- 1
utils/prometheus-node-exporter-lua/Makefile View File

@ -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 <champetier.etienne@gmail.com>
PKG_LICENSE:=Apache-2.0


+ 6
- 2
utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/wifi_stations.lua View File

@ -2,9 +2,10 @@ 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","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", {})
@ -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


Loading…
Cancel
Save