From 820a7b454a7a4527b911fb51131ec764a6e0323b Mon Sep 17 00:00:00 2001 From: Sheppy Date: Thu, 10 Oct 2024 21:23:20 +0000 Subject: [PATCH] feat: check for alternative http codes --- icinga.py | 3 ++- templates/icinga_host.conf.j2 | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/icinga.py b/icinga.py index 024294a..ea6e460 100644 --- a/icinga.py +++ b/icinga.py @@ -10,7 +10,8 @@ def createMasterHostConfig(vmList): continue checkDomains = filter(lambda x: not x.get("nocheck"), vmo.subdomains) - websites = [ (s["name"], s.get("url")) for s in checkDomains] + + websites = [ (s["name"], s.get("url"), [ str(x) for x in s.get("check-expect") or [] ]) for s in checkDomains] f.write(template.render(hostname=vmo.hostname, address=vmo.ip, websites=websites)) def createMasterServiceConfig(vmList): diff --git a/templates/icinga_host.conf.j2 b/templates/icinga_host.conf.j2 index 8b86d25..62d266d 100644 --- a/templates/icinga_host.conf.j2 +++ b/templates/icinga_host.conf.j2 @@ -15,7 +15,7 @@ object Host "{{ hostname }}" { # groups = ["icingaadmins"] # } - {% for website_name, url in websites %} + {% for website_name, url, check_expect in websites %} vars.http_vhosts["{{ website_name }}"] = { {% if url %} http_uri = "{{ url }}" @@ -23,8 +23,13 @@ object Host "{{ hostname }}" { http_uri = "/" {% endif %} http_address = "{{ website_name }}" + http_vhost = "{{ website_name }}" + http_sni = true http_ssl = true http_onredirect = "follow" + {% if check_expect %} + http_expect = "{{ ','.join(check_expect) }}" + {% endif %} } {% endfor %}