for now I´m getting a mail from a service´s warning state every 30 minutes. Is there a way to define, in which time frame a re-notification should be sent?
You need to configure the notification interval within your notification object. Details are documented here
With your current config, you (re-)check only every 24h but send notification about this check result every 30min, which is the default notification interval.
Thanks, do you know, how I can use this object notification for one single service via apply rule only? I´ve tried the following, but the default service notification is executed also:
apply Notification "ssl-notification" to Service {
import "mail-service-notification"
types = [ Problem, Recovery ]
states = [ OK, Warning, Critical, Unknown ]
user_groups = host.vars.notification.mail.groups
users = host.vars.notification.mail.users
interval = 86400
assign where service.name == "ssl"
}
You can get conditional about it in the parent template there:
if (service.name == "ssl") {
interval = 86400
}
Something else I do since my notifications also tend to blanket a ton of things is this:
assign where host.vars.notification.bto.pagerduty == true
assign where service.vars.notification.bto.pagerduty == true
ignore where service.vars.nopagerduty == true
That’s from my pagerduty notification object. I just toss service.vars.nopagerduty on any service object I don’t want to page me since it’s far less common than the ones that should.
Thanks, ah, I think I´ven´t explained it very well: every ssl service check should have this notification type. I think the if condition from @blakehartshorn works!
Thanks - so if two notifications are assigned (the general and the notification for ssl only), how does icinga know, which notification rule is the right one or has priority?
Neither has, they will generate colliding objects. You’ll need to take advantage and define the exceptions inside the assign where parts. There’s also the possibility to use ignore where for instance.
That’s the thing with two or more notification apply rules. The solution from @blakehartshorn is far more advanced with only having one notification apply rule but inline conditions.
We invented conditions with if-then-else for exactly solving such questions asked on the community channels Still, you may need to reconsider for many apply rules, especially when you are going the Icinga Director route at some point, where inline DSL doesn’t work.
Something like this, combined into one generic notification apply rule:
apply Notification "notification" to Service {
import "mail-service-notification"
types = [ Problem, Recovery ]
states = [ OK, Warning, Critical, Unknown ]
user_groups = host.vars.notification.mail.groups
users = host.vars.notification.mail.users
if (service.check_command == "ssl") {
interval = 86400
} else if (...) {
// a different handling again?
} else {
// a default maybe, overriding the default of 30m?
}
assign where ... //previous one for general notifications
}