feat: icinga message parser

This commit is contained in:
2023-07-24 16:54:57 +02:00
parent 80874c7127
commit 6b8ff25de6

View File

@@ -6,7 +6,21 @@ class UnsupportedStruct(Exception):
super().__init__(self.message)
def make_icinga_message(struct):
pass
first_line = "{state} - {service} ({host})".format(state=struct.get("state"),
service=struct.get("service_name"), host=struct.get("service_host"))
second_line = struct.get("service_output") or ""
third_line = "Direkt-Link: {link}".format(link=struct.get("icingaeweb_url"))
if not struct.get("owners") and not struct.get("owner-groups"):
fourth_line = "Notification to: admins (default)"
else:
owners = struct.get("owners") or []
groups = struct.get("owner-groups") or []
groups_strings = [ g + "-group" for g in groups ]
fourth_line = "Notification to: " + ", ".join(owners) + " " + ", ".join(groups_strings)
return "\n".join([first_line, second_line, third_line, fourth_line])
def make_generic_message(struct):
pass