You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1013 B

  1. local ubus = require "ubus"
  2. local iwinfo = require "iwinfo"
  3. local function scrape()
  4. local metric_wifi_station_signal = metric("wifi_station_signal","gauge")
  5. local metric_wifi_station_tx_packets = metric("wifi_station_tx_packets","gauge")
  6. local metric_wifi_station_rx_packets = metric("wifi_station_rx_packets","gauge")
  7. local u = ubus.connect()
  8. local status = u:call("network.wireless", "status", {})
  9. for dev, dev_table in pairs(status) do
  10. for _, intf in ipairs(dev_table['interfaces']) do
  11. local ifname = intf['ifname']
  12. local iw = iwinfo[iwinfo.type(ifname)]
  13. local assoclist = iw.assoclist(ifname)
  14. for mac, station in pairs(assoclist) do
  15. local labels = {
  16. ifname = ifname,
  17. mac = mac,
  18. }
  19. metric_wifi_station_signal(labels, station.signal)
  20. metric_wifi_station_tx_packets(labels, station.tx_packets)
  21. metric_wifi_station_rx_packets(labels, station.rx_packets)
  22. end
  23. end
  24. end
  25. end
  26. return { scrape = scrape }