diff --git a/bundles/icinga2/files/scripts/icinga_notification_wrapper b/bundles/icinga2/files/scripts/icinga_notification_wrapper index 1fe43b0..98a3a47 100644 --- a/bundles/icinga2/files/scripts/icinga_notification_wrapper +++ b/bundles/icinga2/files/scripts/icinga_notification_wrapper @@ -11,6 +11,14 @@ from sys import argv SIPGATE_USER='${node.metadata['icinga2']['sipgate_user']}' SIPGATE_PASS='${node.metadata['icinga2']['sipgate_pass']}' +STATUS_TO_EMOJI = { + 'critical': '๐Ÿ”ฅ', + 'down': '๐Ÿšจ๐Ÿšจ๐Ÿšจ', + 'ok': '๐Ÿ†—', + 'up': '๐Ÿ‘Œ', + 'warning': 'โšกโšก', +} + parser = ArgumentParser( prog='icinga_notification_wrapper', description='Icinga2 Notification Wrapper', @@ -59,13 +67,27 @@ def log_to_syslog(message): def notify_per_sms(): - message = { - 'message': 'ICINGA: {host}{service} is {state}: {output}'.format( + if args.state.lower() in ['up', 'ok']: + output_text = '' + else: + output_text = '\n\n{}'.format(args.output) + if args.state.lower() in STATUS_TO_EMOJI: + message_text = '{emoji} {host}{service} {emoji}{output}'.format( + emoji=STATUS_TO_EMOJI[args.state.lower()], host=args.host_name, service=('/'+args.service_name if args.service_name else ''), state=args.state.upper(), - output=args.output - ), + output=output_text, + ) + else: + message_text = 'ICINGA: {host}{service} is {state}{output}'.format( + host=args.host_name, + service=('/'+args.service_name if args.service_name else ''), + state=args.state.upper(), + output=output_text, + ) + message = { + 'message': message_text, 'smsId': 's0', # XXX what does this mean? Documentation is unclear 'recipient': args.sms }