File: monitoring.lua.j2

package info (click to toggle)
knot-resolver 6.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 16,392 kB
  • sloc: javascript: 42,732; ansic: 40,312; python: 12,616; cpp: 2,121; sh: 1,997; xml: 193; makefile: 181
file content (33 lines) | stat: -rw-r--r-- 1,018 bytes parent folder | download
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