mirror of
https://github.com/openwrt/packages.git
synced 2025-12-26 11:16:31 +04:00
prometheus-node-exporter-lua: add snmp6 exporter
If you want statistics about IPv6 you can use snmpv6 exporter. Currently, the "/proc/net/snmp6" is existing but all values are just "0". To use this plugin you have to set CONFIG_PROC_STRIPPED=n I will find a way to enable the important ipv6 statistics by default. Signed-off-by: Nick Hainke <vincent@systemli.org>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
local ubus = require "ubus"
|
||||
|
||||
local function get_devices() -- based on hostapd_stations.lua
|
||||
local u = ubus.connect()
|
||||
local status = u:call("network.device", "status", {})
|
||||
local devices = {}
|
||||
|
||||
for dev, dev_table in pairs(status) do
|
||||
table.insert(devices, dev)
|
||||
end
|
||||
return devices
|
||||
end
|
||||
|
||||
local function get_metric(device)
|
||||
local label = {
|
||||
device = device
|
||||
}
|
||||
|
||||
if device == "all" then
|
||||
for e in io.lines("/proc/net/snmp6") do
|
||||
local snmp6 = space_split(e)
|
||||
metric("snmp6_" .. snmp6[1], "counter", label, tonumber(snmp6[2]))
|
||||
end
|
||||
else
|
||||
for e in io.lines("/proc/net/dev_snmp6/" .. device) do
|
||||
local snmp6 = space_split(e)
|
||||
metric("snmp6_" .. snmp6[1], "counter", label, tonumber(snmp6[2]))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function scrape()
|
||||
get_metric("all")
|
||||
for _, devicename in ipairs(get_devices()) do
|
||||
get_metric(devicename)
|
||||
end
|
||||
end
|
||||
|
||||
return { scrape = scrape }
|
||||
Reference in New Issue
Block a user