diff options
author | Gérondal Thibault <contact@tycale.be> | 2020-07-03 23:21:12 +0200 |
---|---|---|
committer | Paul Spooren <mail@aparcar.org> | 2020-07-20 13:11:04 -1000 |
commit | e2b3fec6bfca8e9843aa5ec297803869061d2a5d (patch) | |
tree | 6f47089905df126167e6ad6d72bc8949fa74c092 /utils/prometheus-node-exporter-lua/files/usr/lib/lua | |
parent | f4e878c215d0cfd2acfc2cf823e7900e7bb0dd80 (diff) |
prometheus-node-exporter-lua: uci_dhcp_host module
Extract data from configuration file /etc/config/dhcp and create labels
{name, ip, mac, dns} via uci. Those labels are useful in order to craft
complex prometheus queries as replacing the MAC address to a custom
name. E.g.: wifi_station_signal_dbm * on (mac) group_left(name)
uci_dhcp_host or on (mac) label_replace(wifi_station_signal_dbm, "name",
"$1", "mac", "(.+)")
Signed-off-by: Gérondal Thibault <contact@tycale.be>
Diffstat (limited to 'utils/prometheus-node-exporter-lua/files/usr/lib/lua')
-rw-r--r-- | utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/uci_dhcp_host.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/uci_dhcp_host.lua b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/uci_dhcp_host.lua new file mode 100644 index 000000000..950962599 --- /dev/null +++ b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/uci_dhcp_host.lua @@ -0,0 +1,15 @@ +local uci=require("uci") + +local function scrape() + local curs=uci.cursor() + local metric_uci_host = metric("uci_dhcp_host", "gauge") + + curs:foreach("dhcp", "host", function(s) + if s[".type"] == "host" then + labels = {name=s["name"], mac=string.upper(s["mac"]), dns=s["dns"], ip=s["ip"]} + metric_uci_host(labels, 1) + end + end) +end + +return { scrape = scrape } |