Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion utils/prometheus-node-exporter-lua/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=prometheus-node-exporter-lua
PKG_VERSION:=2025.07.15
PKG_VERSION:=2025.11.22
PKG_RELEASE:=1

PKG_MAINTAINER:=Etienne CHAMPETIER <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ _log() {
start_service() {
. /lib/functions/network.sh

local interface port listenflag cert key bind4 bind6
local interface port listenflag cert key bind4 bind6 omit_zero_values

config_load prometheus-node-exporter-lua.main
config_get keepalive "main" http_keepalive 70
config_get interface "main" listen_interface "loopback"
config_get port "main" listen_port 9100
config_get cert "main" cert
config_get key "main" key
config_get omit_zero_values "main" omit_zero_values 0

[ "$interface" = "*" ] || {
network_get_ipaddr bind4 "$interface"
Expand All @@ -31,6 +32,8 @@ start_service() {

procd_open_instance

[ "$omit_zero_values" -eq 1 ] && procd_set_param env OMIT_ZERO_VALUES=1

procd_set_param command /usr/sbin/uhttpd -f -c /dev/null -l / -L /usr/bin/prometheus-node-exporter-lua
[ $keepalive -gt 0 ] && procd_append_param command -k $keepalive

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

socket = require("socket")

-- get configs

local omit_zero_values = os.getenv("OMIT_ZERO_VALUES") == "1"

-- Parsing

function space_split(s)
Expand Down Expand Up @@ -50,8 +54,12 @@ end

function metric(name, mtype, labels, value)
out:write("# TYPE ", name, " ", mtype, "\n")
-- omit_zero_vales config supress time series always being zero
local printall = not (mtype == "counter" and omit_zero_values)
local outputter = function(labels, value)
print_metric(name, labels, value)
if printall or tonumber(value) ~= 0 then
print_metric(name, labels, value)
end
end
if value then
outputter(labels, value)
Expand Down