bundles/icinga2: notify per sms if ntfy does not respond in time

This commit is contained in:
Franzi 2024-11-23 13:30:22 +01:00
parent a9b16c18ad
commit 3a5db80843
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -129,11 +129,14 @@ def notify_per_ntfy():
data=message_text,
headers=headers,
auth=(CONFIG['ntfy']['user'], CONFIG['ntfy']['password']),
timeout=10,
)
r.raise_for_status()
except Exception as e:
log_to_syslog('Sending a Notification failed: {}'.format(repr(e)))
return False
return True
def notify_per_mail():
@ -199,7 +202,8 @@ if __name__ == '__main__':
notify_per_mail()
if args.sms:
if not args.service_name:
notify_per_sms()
ntfy_worked = False
if CONFIG['ntfy']['user']:
notify_per_ntfy()
ntfy_worked = notify_per_ntfy()
if not args.service_name or not ntfy_worked:
notify_per_sms()