bundles/icinga2: notify per sms if ntfy does not respond in time
This commit is contained in:
parent
a9b16c18ad
commit
3a5db80843
1 changed files with 7 additions and 3 deletions
|
@ -129,11 +129,14 @@ def notify_per_ntfy():
|
||||||
data=message_text,
|
data=message_text,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
auth=(CONFIG['ntfy']['user'], CONFIG['ntfy']['password']),
|
auth=(CONFIG['ntfy']['user'], CONFIG['ntfy']['password']),
|
||||||
|
timeout=10,
|
||||||
)
|
)
|
||||||
|
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log_to_syslog('Sending a Notification failed: {}'.format(repr(e)))
|
log_to_syslog('Sending a Notification failed: {}'.format(repr(e)))
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def notify_per_mail():
|
def notify_per_mail():
|
||||||
|
@ -199,7 +202,8 @@ if __name__ == '__main__':
|
||||||
notify_per_mail()
|
notify_per_mail()
|
||||||
|
|
||||||
if args.sms:
|
if args.sms:
|
||||||
if not args.service_name:
|
ntfy_worked = False
|
||||||
notify_per_sms()
|
|
||||||
if CONFIG['ntfy']['user']:
|
if CONFIG['ntfy']['user']:
|
||||||
notify_per_ntfy()
|
ntfy_worked = notify_per_ntfy()
|
||||||
|
if not args.service_name or not ntfy_worked:
|
||||||
|
notify_per_sms()
|
||||||
|
|
Loading…
Reference in a new issue