Exclude check for a service in a specific time range


(Lucas Possamai) #1

Hi all.

I have daily backups on my Oracle DB server between 1am to 4am. That makes the load on the server triggers an alert.

I’d like to exclude the notifications for that specific service between that time. It would be nice if I could do this per host as well but not mandatory.

I had a look at the Time Periods documentation section, and I came up with this:

object TimePeriod "24x7" {
  display_name = "Icinga 2 24x7 TimePeriod"
  
  excludes = [ "early-morning-excluded" ]
  
  ranges = {
    "monday"    = "00:00-24:00"
    "tuesday"   = "00:00-24:00"
    "wednesday" = "00:00-24:00"
    "thursday"  = "00:00-24:00"
    "friday"    = "00:00-24:00"
    "saturday"  = "00:00-24:00"
    "sunday"    = "00:00-24:00"
  }
}

timeperiods.conf:

object TimePeriod "early-morning-excluded" {

  ranges = {
    "monday"   = "01:00-05:00"
    "tuesday"   = "01:00-05:00"
    "wednesday" = "01:00-05:00"
    "thursday"  = "01:00-05:00"
    "friday"    = "01:00-05:00"
    "saturday"  = "01:00-05:00"
    "sunday"    = "01:00-05:00"
  }
}

Then, how could I add that “early-morning-excluded” to a specific service?

This part probably adds that exclusion rule to all services, correct?

object TimePeriod "24x7" {
  display_name = "Icinga 2 24x7 TimePeriod"
  
  excludes = [ "early-morning-excluded" ]

#2

https://icinga.com/docs/icinga2/latest/doc/08-advanced-topics/#time-periods

apply Notification “mail-icingaadmin” to Service {
import “mail-service-notification”
user_groups = host.vars.notification.mail.groups
users = host.vars.notification.mail.users
period = “workhours”
assign where host.vars.notification.mail
}


(Carsten Köbke) #3

Why nott set a ScheduledDowntime for that service? So Icinga still checks, but no notification is sent during the downtime.


(Lucas Possamai) #4

Thanks @Carsten. I did do that and forgot to post here the solution.

This is working for me:

apply ScheduledDowntime "backup-downtime" to Service {
  author = "icingaadmin"
  comment = "Scheduled downtime for backup"

 service_name = "load"

  ranges = {
    monday = "01:30-05:00" 
    tuesday = "01:30-05:00" 
    wednesday = "01:30-05:00"
    thursday = "01:30-05:00"
    friday = "01:30-05:00"
    saturday = "01:30-05:00"
    sunday = "01:30-05:00"
  }

  assign where service.vars.backup_downtime == "yes"
} 

This way I can assign the scheduled downtime to one or more hosts using the custom variable "backup_downtime == "yes"".

Cheers