include $(TOPDIR)/rules.mk
PKG_NAME:=prometheus-node-exporter-lua
-PKG_VERSION:=2022.08.08
+PKG_VERSION:=2023.05.14
PKG_RELEASE:=1
PKG_MAINTAINER:=Etienne CHAMPETIER <champetier.etienne@gmail.com>
$(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/textfile.lua $(1)/usr/lib/lua/prometheus-collectors/
endef
+define Package/prometheus-node-exporter-lua-thermal
+ $(call Package/prometheus-node-exporter-lua/Default)
+ TITLE+= (thermal collector)
+ DEPENDS:=prometheus-node-exporter-lua
+endef
+
+define Package/prometheus-node-exporter-lua-thermal/install
+ $(INSTALL_DIR) $(1)/usr/lib/lua/prometheus-collectors
+ $(INSTALL_BIN) ./files/usr/lib/lua/prometheus-collectors/thermal.lua $(1)/usr/lib/lua/prometheus-collectors/
+endef
+
define Package/prometheus-node-exporter-lua-ubnt-manager
$(call Package/prometheus-node-exporter-lua/Default)
TITLE+= (ubnt-manager collector)
$(eval $(call BuildPackage,prometheus-node-exporter-lua-netstat))
$(eval $(call BuildPackage,prometheus-node-exporter-lua-openwrt))
$(eval $(call BuildPackage,prometheus-node-exporter-lua-textfile))
+$(eval $(call BuildPackage,prometheus-node-exporter-lua-thermal))
$(eval $(call BuildPackage,prometheus-node-exporter-lua-ubnt-manager))
$(eval $(call BuildPackage,prometheus-node-exporter-lua-uci_dhcp_host))
$(eval $(call BuildPackage,prometheus-node-exporter-lua-wifi))
--- /dev/null
+-- thermal collector
+local function scrape()
+ local i = 0
+ local temp_metric = metric("node_thermal_zone_temp", "gauge")
+
+ while true do
+ local zonePath = "/sys/class/thermal/thermal_zone" .. i
+
+ -- required attributes
+
+ local typ = string.match(get_contents(zonePath .. "/type"), "^%s*(.-)%s*$")
+ if not typ then
+ break
+ end
+
+ local policy = string.match(get_contents(zonePath .. "/policy"), "^%s*(.-)%s*$")
+ if not policy then
+ break
+ end
+
+ local temp = string.match(get_contents(zonePath .. "/temp"), "(%d+)")
+ if not temp then
+ break
+ end
+
+ local labels = {zone = i, type = typ, policy = policy}
+
+ -- optional attributes
+
+ local mode = string.match(get_contents(zonePath .. "/mode"), "^%s*(.-)%s*$")
+ if mode then
+ labels.mode = mode
+ end
+
+ local passive = string.match(get_contents(zonePath .. "/passive"), "(%d+)")
+ if passive then
+ labels.passive = passive
+ end
+
+ temp_metric(labels, temp / 1000)
+
+ i = i + 1
+ end
+end
+
+return { scrape = scrape }