Set notification interval for specific service

I currently have a notification object:

apply Notification "mail-icingaadmin" to Service {
  import "mail-service-notification"
  user_groups = host.vars.notification.mail.groups
  users = host.vars.notification.mail.users
  if(service.name == "yum"){
    interval = 24h
  }
  assign where host.vars.notification.mail && host.vars.emergency
}

Notifications are working and are sending every 30 minutes. I’d like to be able to change the notification interval for the yum service only. Trying to set it like the above gives:

“Unit icinga2.service entered failed state.
icinga2.service failed.”

What is the correct way of doing this?

Thanks,
Daniel

Hi and welcome to the community,

there is a missing = in your if expression:

if(service.name == "yum"){
    interval = 24h
}

You should also validate your config to get possible errors and more information (before restarting the service).

Greetz

1 Like

Hi there,

Thank you for the quick reply, but I did spot this shortly after the question was posted.
Sorry, I should have updated the question sooner.

The icinga service is now running, however I’m not getting the desired outcome of the yum process notifications only being sent every 24hrs. (I just received another email a few minutes ago)

Any other ideas?

Hi,

try it with the service check_command instead:

if (service.check_command == "yum") {
    interval = 24h
}

Greetz

1 Like

I think that’s got it! Thank you :slight_smile:

Hi again,

It seemed to have worked for 1 day only… I’m just now getting the notifications again. It seems like the interval was for 24 hours and then went back to being every 30 minutes.
The notification object has not been changed.

Does anybody have a clue why this could be happening?

Hi there,

I currently have a notification object:

apply Notification "mail-icingaadmin" to Service {
  import "mail-service-notification"
  user_groups = host.vars.notification.mail.groups
  users = host.vars.notification.mail.users
  if (service.check_command == "yum") {
    interval = 24h
  }
  assign where host.vars.notification.mail && host.vars.emergency
}

This worked for 24 hours. After that, the notifications came back and are back to sending every 30 minutes now.

Does anyone have an idea on why this might be the case?

Merged the new topic into the existing one. Next time, please be patient and wait.

You can speed things up with providing more details about your problem. This includes full configuration on how to reproduce this, object inspection from object list and the REST API, and with notifications, logs and debug logs. If you’re not sure what to provide, check the troubleshooting docs.

Regards,
Michael

Hi Michael, sorry about that. Wasn’t sure if it deserved another topic as the issue had changed from what it was originally.