# Service: set re-notification time

**URL:** <https://community.icinga.com/t/service-set-re-notification-time/1058>\
**Category:** Icinga 2\
**Tags:** notifications, icinga2\
**Created:** [April 30, 2019, 8:23am UTC](https://community.icinga.com/t/service-set-re-notification-time/1058 "2019-04-30T08:23:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![meisterpropper](https://community.icinga.com/user_avatar/community.icinga.com/meisterpropper/32/354_2.png) [@meisterpropper](https://community.icinga.com/u/meisterpropper)\
**Post date:** [April 30, 2019, 8:23am UTC](https://community.icinga.com/t/service-set-re-notification-time/1058/1 "2019-04-30T08:23:18Z")

</div>

Hi,

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?

My service is defined like:

```
apply Service "ssl" {
    import "ssl-service"
    vars.ssl_port = "443"
    vars.ssl_cert_valid_days_warn = "30"
    vars.notification.interval = 0
    check_command = "ssl"
    assign where host.vars.ssl_proxy
}

```

template:

```
template Service "ssl-service" {
  max_check_attempts = 3
  check_interval = 1440m
  retry_interval = 1440m
}

```

I´m trying to achieve a re-notification every / once a day.

---

<div class="post-metadata">

**Author:** ![rsx](https://community.icinga.com/user_avatar/community.icinga.com/rsx/32/2094_2.png) [@rsx](https://community.icinga.com/u/rsx)\
**Post date:** [April 30, 2019, 8:57am UTC](https://community.icinga.com/t/service-set-re-notification-time/1058/2 "2019-04-30T08:57:05Z")

</div>

You need to configure the notification interval within your notification object. Details are documented [here](https://icinga.com/docs/icinga2/latest/doc/09-object-types/#notification)

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.

---

<div class="post-metadata">

**Author:** ![meisterpropper](https://community.icinga.com/user_avatar/community.icinga.com/meisterpropper/32/354_2.png) [@meisterpropper](https://community.icinga.com/u/meisterpropper)\
**Post date:** [April 30, 2019, 11:06am UTC](https://community.icinga.com/t/service-set-re-notification-time/1058/3 "2019-04-30T11:06:15Z")

</div>

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"
}
```

---

<div class="post-metadata">

**Author:** ![blakehartshorn](https://community.icinga.com/user_avatar/community.icinga.com/blakehartshorn/32/599_2.png) [@blakehartshorn](https://community.icinga.com/u/blakehartshorn)\
**Post date:** [April 30, 2019, 11:27am UTC](https://community.icinga.com/t/service-set-re-notification-time/1058/4 "2019-04-30T11:27:14Z")

</div>

You can get conditional about it in the parent template there:

```auto
if (service.name == "ssl") {
  interval = 86400
}

```

Something else I do since my notifications also tend to blanket a ton of things is this:

```auto
  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.

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [April 30, 2019, 12:11pm UTC](https://community.icinga.com/t/service-set-re-notification-time/1058/5 "2019-04-30T12:11:18Z")

</div>

If you prefer to affect a single service object tied to a host object, the assign where expression is pretty expensive, like

```auto
assign where host.name == "bla" && service.name == "ssl"

```

Instead, use the object notation here which defines `host_name` and `service_name` as Notification object attributes:

```auto
object Notification "ssl-notification" {
  ...
  host_name = "bla"
  service_name = "ssl"
}

```

These two attributes automatically identify this a service notification.

Cheers,  
Michael

---

<div class="post-metadata">

**Author:** ![meisterpropper](https://community.icinga.com/user_avatar/community.icinga.com/meisterpropper/32/354_2.png) [@meisterpropper](https://community.icinga.com/u/meisterpropper)\
**Post date:** [April 30, 2019, 12:17pm UTC](https://community.icinga.com/t/service-set-re-notification-time/1058/6 "2019-04-30T12:17:32Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [April 30, 2019, 12:37pm UTC](https://community.icinga.com/t/service-set-re-notification-time/1058/7 "2019-04-30T12:37:33Z")

</div>

Ah. Yeah, then something from the hidden germs: You can also just go for the `check_command` attribute, instead of the naming parts 🙂

```auto
assign where service.check_command == "ssl"

```

That way your services can use a different name (renaming can happen) and your notifications are still intact.

Cheers,  
Michael

---

<div class="post-metadata">

**Author:** ![meisterpropper](https://community.icinga.com/user_avatar/community.icinga.com/meisterpropper/32/354_2.png) [@meisterpropper](https://community.icinga.com/u/meisterpropper)\
**Post date:** [April 30, 2019, 12:39pm UTC](https://community.icinga.com/t/service-set-re-notification-time/1058/8 "2019-04-30T12:39:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [April 30, 2019, 12:44pm UTC](https://community.icinga.com/t/service-set-re-notification-time/1058/9 "2019-04-30T12:44:27Z")

</div>

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:

```auto
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
}

```

Cheers,  
Michael
