mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 07:28:39 +01:00
prometheus-node-exporter-lua: fix missing conntrack values
If the /proc/sys/net/netfilter/nc_conntrack_* files are not present,
this exporter was outputting a blank value, which is invalid. These
files will not be present when using an image that doesn't include the
iptables and firewall packages (eg a minimal access-point type image).
This updates the collector to only output the metrics if the
corresponding /proc files are present.
Signed-off-by: Alex Tomlins <alex@tomlins.org.uk>
(cherry picked from commit 0100a2cb26)
This commit is contained in:
committed by
Etienne Champetier
parent
70bd5a36cd
commit
b03545e0bc
+8
-4
@@ -1,8 +1,12 @@
|
|||||||
local function scrape()
|
local function scrape()
|
||||||
metric("node_nf_conntrack_entries", "gauge", nil,
|
local count = get_contents("/proc/sys/net/netfilter/nf_conntrack_count")
|
||||||
string.sub(get_contents("/proc/sys/net/netfilter/nf_conntrack_count"), 1, -2))
|
local max = get_contents("/proc/sys/net/netfilter/nf_conntrack_max")
|
||||||
metric("node_nf_conntrack_entries_limit", "gauge", nil,
|
if count ~= "" then
|
||||||
string.sub(get_contents("/proc/sys/net/netfilter/nf_conntrack_max"), 1, -2))
|
metric("node_nf_conntrack_entries", "gauge", nil, string.sub(count, 1, -2))
|
||||||
|
end
|
||||||
|
if max ~= "" then
|
||||||
|
metric("node_nf_conntrack_entries_limit", "gauge", nil, string.sub(max, 1, -2))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return { scrape = scrape }
|
return { scrape = scrape }
|
||||||
|
|||||||
Reference in New Issue
Block a user