bundles/icinga2: do not send recovery emails
This commit is contained in:
parent
763a071acc
commit
c5eb2f4f70
3 changed files with 13 additions and 44 deletions
|
@ -29,9 +29,7 @@ object NotificationCommand "send-host-notification" {
|
||||||
"--host_name" = "$host.display_name$"
|
"--host_name" = "$host.display_name$"
|
||||||
"--state" = "$host.state$"
|
"--state" = "$host.state$"
|
||||||
"--output" = "$host.output$"
|
"--output" = "$host.output$"
|
||||||
"--escalation" = {
|
"--notification-type" = "$notification.type$"
|
||||||
set_if = "$escalation$"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,8 +65,6 @@ object NotificationCommand "send-service-notification" {
|
||||||
"--service_name" = "$service.display_name$"
|
"--service_name" = "$service.display_name$"
|
||||||
"--state" = "$service.state$"
|
"--state" = "$service.state$"
|
||||||
"--output" = "$service.output$"
|
"--output" = "$service.output$"
|
||||||
"--escalation" = {
|
"--notification-type" = "$notification.type$"
|
||||||
set_if = "$escalation$"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,55 +3,23 @@ apply Notification "notify_host-notification" to Host {
|
||||||
interval = 30m
|
interval = 30m
|
||||||
|
|
||||||
times = {
|
times = {
|
||||||
begin = 1m
|
begin = 0m
|
||||||
end = 30m
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assign where host.vars.notification.sms == true
|
assign where host.vars.notification.sms == true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
apply Notification "notify_service-notification" to Service {
|
apply Notification "notify_service-notification" to Service {
|
||||||
import "service-notification"
|
import "service-notification"
|
||||||
interval = 30m
|
interval = 30m
|
||||||
|
|
||||||
times = {
|
times = {
|
||||||
begin = 1m
|
begin = 0m
|
||||||
end = 30m
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assign where service.vars.notification.sms == true
|
assign where service.vars.notification.sms == true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
apply Notification "notify_host-notification-escalation" to Host {
|
|
||||||
import "host-notification"
|
|
||||||
interval = 20m
|
|
||||||
|
|
||||||
times = {
|
|
||||||
begin = 30m
|
|
||||||
}
|
|
||||||
|
|
||||||
vars.escalation = true
|
|
||||||
|
|
||||||
assign where host.vars.notification.sms == true
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
apply Notification "notify_service-notification-escalation" to Service {
|
|
||||||
import "service-notification"
|
|
||||||
interval = 20m
|
|
||||||
|
|
||||||
times = {
|
|
||||||
begin = 30m
|
|
||||||
}
|
|
||||||
|
|
||||||
vars.escalation = true
|
|
||||||
|
|
||||||
assign where service.vars.notification.sms == true
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
apply Notification "notify_service-notification-mail" to Service {
|
apply Notification "notify_service-notification-mail" to Service {
|
||||||
import "service-notification"
|
import "service-notification"
|
||||||
interval = 0
|
interval = 0
|
||||||
|
|
|
@ -51,8 +51,9 @@ parser.add_argument(
|
||||||
type=str,
|
type=str,
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--escalation',
|
'--notification-type',
|
||||||
action='store_true',
|
type=str,
|
||||||
|
required=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def log_to_syslog(message):
|
def log_to_syslog(message):
|
||||||
|
@ -67,7 +68,7 @@ def log_to_syslog(message):
|
||||||
|
|
||||||
|
|
||||||
def notify_per_sms():
|
def notify_per_sms():
|
||||||
if args.state.lower() in ['up', 'ok']:
|
if args.notification_type.lower() == 'recovery':
|
||||||
output_text = ''
|
output_text = ''
|
||||||
else:
|
else:
|
||||||
output_text = '\n\n{}'.format(args.output)
|
output_text = '\n\n{}'.format(args.output)
|
||||||
|
@ -112,6 +113,10 @@ def notify_per_sms():
|
||||||
|
|
||||||
|
|
||||||
def notify_per_mail():
|
def notify_per_mail():
|
||||||
|
if args.notification_type.lower() == 'recovery':
|
||||||
|
# Do not send recovery emails.
|
||||||
|
return
|
||||||
|
|
||||||
# editorconfig-checker-disable
|
# editorconfig-checker-disable
|
||||||
text = """
|
text = """
|
||||||
_ _
|
_ _
|
||||||
|
@ -166,7 +171,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
log_to_syslog(' '.join(argv))
|
log_to_syslog(' '.join(argv))
|
||||||
|
|
||||||
if args.mail and not args.escalation:
|
if args.mail:
|
||||||
notify_per_mail()
|
notify_per_mail()
|
||||||
|
|
||||||
if args.sms:
|
if args.sms:
|
||||||
|
|
Loading…
Reference in a new issue