mirror of
https://github.com/FAUSheppy/atlantis-event-dispatcher
synced 2025-12-07 06:51:35 +01:00
feat: icinga message parser
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user