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.

30 lines
800 B

  1. local netsubstat = {
  2. "IcmpMsg",
  3. "Icmp",
  4. "IpExt",
  5. "Ip",
  6. "TcpExt",
  7. "Tcp",
  8. "UdpLite",
  9. "Udp"
  10. }
  11. local function scrape()
  12. -- NOTE: Both of these are missing in OpenWRT kernels.
  13. -- See: https://dev.openwrt.org/ticket/15781
  14. local netstat = get_contents("/proc/net/netstat") .. get_contents("/proc/net/snmp")
  15. -- all devices
  16. for i, nss in ipairs(netsubstat) do
  17. local substat_s = string.match(netstat, nss .. ": ([A-Z][A-Za-z0-9 ]+)")
  18. if substat_s then
  19. local substat = space_split(substat_s)
  20. local substatv = space_split(string.match(netstat, nss .. ": ([0-9 -]+)"))
  21. for ii, ss in ipairs(substat) do
  22. metric("node_netstat_" .. nss .. "_" .. ss, "gauge", nil, substatv[ii])
  23. end
  24. end
  25. end
  26. end
  27. return { scrape = scrape }