luci-app-statistics: stat-genconfig: don't emit bools for absent uci options

Do not emit native collectd.conf boolean false options if the corresponding
uci option is unset in order to honour collectd's implicit defaults.

This fixes certain options, such as the memory plugins `ValuesAbsolute`,
being without effect if declared as default-enabled in the related plugin
uci forms.

Fixes: #5777
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit f16037cec5)
This commit is contained in:
Jo-Philipp Wich 2022-04-25 20:55:02 +02:00
parent 3645670952
commit 46794ea2fb

View file

@ -235,13 +235,13 @@ function _bool( s, n, nopad )
local pad = "" local pad = ""
if not nopad then pad = "\t" end if not nopad then pad = "\t" end
if s and s == "1" then if s == "1" then
str = pad .. n .. " true" str = pad .. n .. " true\n"
else elseif s == "0" then
str = pad .. n .. " false" str = pad .. n .. " false\n"
end end
return str .. "\n" return str
end end
function _string( s, n, nopad ) function _string( s, n, nopad )