bundles/icinga2: add some emoji to sent SMS, don't send output via SMS if everything is fine
All checks were successful
bundlewrap/pipeline/head This commit looks good
All checks were successful
bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
bb661b391b
commit
2bccbf9ded
1 changed files with 26 additions and 4 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue