1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
--- control socket location
local ffi = require('ffi')
local id = os.getenv('SYSTEMD_INSTANCE')
if not id then
log_error(ffi.C.LOG_GRP_SYSTEM, 'environment variable $SYSTEMD_INSTANCE not set, which should not have been possible due to running under manager')
else
-- Bind to control socket in CWD (= rundir in config)
-- FIXME replace with relative path after fixing https://gitlab.nic.cz/knot/knot-resolver/-/issues/720
local path = '{{ cwd }}/control/'..id
log_warn(ffi.C.LOG_GRP_SYSTEM, 'path = ' .. path)
local ok, err = pcall(net.listen, path, nil, { kind = 'control' })
if not ok then
log_warn(ffi.C.LOG_GRP_NETWORK, 'bind to '..path..' failed '..err)
end
end
{% if cfg.monitoring.metrics == "always" %}
modules.load('stats')
{% endif %}
--- function used for statistics collection
function collect_lazy_statistics()
if stats == nil then
modules.load('stats')
end
return stats.list()
end
--- function used for statistics collection
function collect_statistics()
return stats.list()
end
|