Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prometheus-node-exporter-lua: tonumber of empty string causing error and dropped metrics #25578

Open
shikasta-net opened this issue Dec 19, 2024 · 1 comment

Comments

@shikasta-net
Copy link

Maintainer: @champtar
Environment: RTL8382, D-Link DGS-1210-16, Openwrt 23.05.4; and RTL8380, D-Link DGS-1210-10MP F, Openwrt 23.05.5

Description:
Log noise and missing metrics caused at:

if speed ~= nil and tonumber(speed) >= 0 then
metric_node_network.speed_bytes({device = device}, tonumber(speed)*1000*1000/8)
end

if speed ~= nil and tonumber(speed) >= 0 then causes

/usr/lib/lua/prometheus-collectors/netclass.lua:36: attempt to compare number with nil

when speed is an empty string, because tonumber('') = nil and nil >= 0 is invalid. Is only an issue on these d-link switches, not linksys wrt3200 router or BT homehub5 accesspoint.

@shikasta-net
Copy link
Author

I tried the obvious thing of adding and speed ~= '' to the conditional but that fails with

/usr/bin/prometheus-node-exporter-lua:42: bad argument #4 to 'format' (string expected, got nil)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant