prometheus-node-exporter-lua: add conntrack collector
authorEtienne Champetier <champetier.etienne@gmail.com>
Wed, 25 Jul 2018 18:43:44 +0000 (20:43 +0200)
committerEtienne Champetier <champetier.etienne@gmail.com>
Wed, 25 Jul 2018 21:27:39 +0000 (23:27 +0200)
Also fix missing dependency of openwrt collector

Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
utils/prometheus-node-exporter-lua/Makefile
utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/conntrack.lua [new file with mode: 0644]

index 3f5ab7f55222792822c79bc74656e9feb797e861..2fc73562ff3beb4071c4ef564e62582ee74cf9bc 100644 (file)
@@ -4,7 +4,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=prometheus-node-exporter-lua
-PKG_VERSION:=2018.06.26
+PKG_VERSION:=2018.07.23
 PKG_RELEASE:=1
 
 PKG_MAINTAINER:=Etienne CHAMPETIER <champetier.etienne@gmail.com>
@@ -79,6 +79,7 @@ endef
 define Package/prometheus-node-exporter-lua-openwrt
   $(call Package/prometheus-node-exporter-lua/Default)
   TITLE+= (openwrt collector)
+  DEPENDS:=prometheus-node-exporter-lua
 endef
 
 Build/Compile=
@@ -92,6 +93,7 @@ define Package/prometheus-node-exporter-lua/install
        $(INSTALL_BIN) ./files/usr/bin/prometheus-node-exporter-lua $(1)/usr/bin/prometheus-node-exporter-lua
        $(INSTALL_DIR) $(1)/usr/lib/lua/prometheus-collectors
        $(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/cpu.lua         $(1)/usr/lib/lua/prometheus-collectors/
+       $(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/conntrack.lua   $(1)/usr/lib/lua/prometheus-collectors/
        $(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/filefd.lua      $(1)/usr/lib/lua/prometheus-collectors/
        $(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/loadavg.lua     $(1)/usr/lib/lua/prometheus-collectors/
        $(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/meminfo.lua     $(1)/usr/lib/lua/prometheus-collectors/
diff --git a/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/conntrack.lua b/utils/prometheus-node-exporter-lua/files/usr/lib/lua/prometheus-collectors/conntrack.lua
new file mode 100644 (file)
index 0000000..93b26c2
--- /dev/null
@@ -0,0 +1,8 @@
+local function scrape()
+  metric("node_nf_conntrack_entries", "gauge", nil,
+    string.sub(get_contents("/proc/sys/net/netfilter/nf_conntrack_count"), 1, -2))
+  metric("node_nf_conntrack_entries_limit", "gauge", nil,
+    string.sub(get_contents("/proc/sys/net/netfilter/nf_conntrack_max"), 1, -2))
+end
+
+return { scrape = scrape }