add config option for instance name

This is needed if you have multiple instances of this
package running side-by-side
This commit is contained in:
Franzi 2020-12-19 09:23:40 +01:00
parent 3d9b6da706
commit 5af7fe2340
Signed by: kunsi
GPG key ID: 12E3D2136B818350
2 changed files with 15 additions and 2 deletions

View file

@ -58,6 +58,13 @@
[30, "30px"], [30, "30px"],
[40, "40px"] [40, "40px"]
] ]
}, {
"title": "instance name",
"ui_width": 12,
"name": "instance_name",
"type": "string",
"default": "icinga2",
"hint": "Something to describe the displayed output, will be shown next to the update datum"
}, { }, {
"title": "Connection to icinga2", "title": "Connection to icinga2",
"type": "section" "type": "section"

View file

@ -45,12 +45,18 @@ function node.render()
end end
end end
local time_width = CONFIG.font:width(services.prettytime, CONFIG.output_size) if CONFIG.instance_name ~= "" then
titlebar = CONFIG.instance_name .. " - " .. services.prettytime
else
titlebar = servics.prettytime
end
local title_width = CONFIG.font:width(titlebar, CONFIG.output_size)
local host_width = 0 local host_width = 0
transform() transform()
CONFIG.background_color.clear() CONFIG.background_color.clear()
CONFIG.font:write(real_width/2-time_width/2, CONFIG.output_size*0.5, services.prettytime, CONFIG.output_size, 1,1,1,1) CONFIG.font:write(real_width/2-title_width/2, CONFIG.output_size*0.5, titlebar, CONFIG.output_size, 1,1,1,1)
for idx, service in ipairs(services.services) do for idx, service in ipairs(services.services) do
host_width = math.max(host_width, CONFIG.font:width(service.host, CONFIG.header_size)) host_width = math.max(host_width, CONFIG.font:width(service.host, CONFIG.header_size))