From 3a5db80843568696ac377a661354a5d26d5814a9 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sat, 23 Nov 2024 13:30:22 +0100 Subject: [PATCH] bundles/icinga2: notify per sms if ntfy does not respond in time --- .../icinga2/files/scripts/icinga_notification_wrapper | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bundles/icinga2/files/scripts/icinga_notification_wrapper b/bundles/icinga2/files/scripts/icinga_notification_wrapper index 612882d..fbecd8e 100644 --- a/bundles/icinga2/files/scripts/icinga_notification_wrapper +++ b/bundles/icinga2/files/scripts/icinga_notification_wrapper @@ -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()