Commit 7beaadea authored by Bernhard Geier's avatar Bernhard Geier
Browse files

add -B for shorter alert messages

parent 2d807736
......@@ -26,6 +26,9 @@ template NotificationCommand "xmpp-notification-base" {
required = true
value = "$notification_type$"
}
"-B" = {
set_if = "$notification_brief$"
}
}
vars += {
......
......@@ -56,42 +56,39 @@ def build_message(args):
if args.servicename:
# service
message = """[{notificationtype}] {servicedisplayname} on {hostdisplayname} is {servicestate}!
{output}
When: {longdatetime}
Ref: {hostname}!{servicename}
Monitoring host: {monitoringhostname}\
""".format(
message = """[{notificationtype}] {servicedisplayname} on {hostdisplayname} is {servicestate}!\n{output}""".format(
notificationtype=args.notificationtype,
monitoringhostname=gethostname(),
servicedisplayname=args.servicedisplayname,
hostdisplayname=args.hostdisplayname,
servicestate=args.state,
output=output,
longdatetime=args.longdatetime,
servicename=args.servicename,
hostname=args.hostname
output=output
)
if not args.brief:
message += """\nWhen: {longdatetime}\nRef: {hostname}!{servicename}\nMonitoring host: {monitoringhostname}""".format(
longdatetime=args.longdatetime,
hostname=args.hostname,
servicename=args.servicename,
monitoringhostname=gethostname()
)
else:
message = """[{notificationtype}] {hostdisplayname} is {hoststate}!
{output}
When: {longdatetime}
Ref: {hostname}
Monitoring host: {monitoringhostname}\
""".format(
message = """[{notificationtype}] {hostdisplayname} is {hoststate}!\n{output}""".format(
notificationtype=args.notificationtype,
monitoringhostname=gethostname(),
hostdisplayname=args.hostdisplayname,
hoststate=args.state,
output=output,
output=output
)
if not args.brief:
message += """\nWhen: {longdatetime}\nRef: {hostname}\nMonitoring host: {monitoringhostname}""".format(
longdatetime=args.longdatetime,
hostname=args.hostname
hostname=args.hostname,
monitoringhostname=gethostname()
)
if args.hostaddress:
if not args.brief and args.hostaddress:
message += "\nIPv4: {}".format(args.hostaddress)
if args.hostaddress6:
if not args.brief and args.hostaddress6:
message += "\nIPv6: {}".format(args.hostaddress6)
if args.notificationcomment:
......@@ -142,6 +139,7 @@ def build_argparser():
parser.add_argument('-b', '--notificationauthorname')
parser.add_argument('-c', '--notificationcomment')
parser.add_argument('-i', '--icingaweb2url')
parser.add_argument('-B', '--brief', default=False, action='store_true')
return parser
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment