2014-02-05 15:53:22 +01:00
|
|
|
## <a id="timeperiods"></a> Time Periods
|
2013-10-10 11:22:32 +02:00
|
|
|
|
2013-10-18 20:05:08 +02:00
|
|
|
Time Periods define time ranges in Icinga where event actions are
|
|
|
|
triggered, for example if a service check is executed or not within
|
|
|
|
the `check_period` attribute. Or a notification should be sent to
|
|
|
|
users or not, filtered by the `notification_period` configuration
|
|
|
|
attribute for `Notification` and `User` objects.
|
|
|
|
|
|
|
|
> **Note**
|
|
|
|
>
|
|
|
|
> If you are familar with Icinga 1.x - these time period definitions
|
|
|
|
> are called `legacy timeperiods` in Icinga 2.
|
|
|
|
>
|
|
|
|
> An Icinga 2 legacy timeperiod requires the `ITL` provided template
|
|
|
|
>`legacy-timeperiod`.
|
|
|
|
|
|
|
|
The `TimePeriod` attribute `ranges` may contain multiple directives,
|
|
|
|
including weekdays, days of the month, and calendar dates.
|
|
|
|
These types may overlap/override other types in your ranges dictionary.
|
|
|
|
|
|
|
|
The descending order of precedence is as follows:
|
|
|
|
|
|
|
|
* Calendar date (2008-01-01)
|
|
|
|
* Specific month date (January 1st)
|
|
|
|
* Generic month date (Day 15)
|
|
|
|
* Offset weekday of specific month (2nd Tuesday in December)
|
|
|
|
* Offset weekday (3rd Monday)
|
|
|
|
* Normal weekday (Tuesday)
|
|
|
|
|
|
|
|
If you don't set any `check_period` or `notification_period` attribute
|
|
|
|
on your configuration objects Icinga 2 assumes `24x7` as time period
|
|
|
|
as shown below.
|
|
|
|
|
2014-03-27 12:30:24 +01:00
|
|
|
object TimePeriod "24x7" {
|
2014-03-31 18:38:15 +02:00
|
|
|
import "legacy-timeperiod"
|
2014-03-27 12:30:24 +01:00
|
|
|
|
2014-03-31 18:38:15 +02:00
|
|
|
display_name = "Icinga 2 24x7 TimePeriod"
|
2013-10-18 20:05:08 +02:00
|
|
|
ranges = {
|
2014-03-31 18:38:15 +02:00
|
|
|
"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"
|
2013-10-18 20:05:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
If your operation staff should only be notified during workhours
|
|
|
|
create a new timeperiod named `workhours` defining a work day with
|
|
|
|
09:00 to 17:00.
|
|
|
|
|
2014-03-27 12:30:24 +01:00
|
|
|
object TimePeriod "workhours" {
|
2014-03-31 18:38:15 +02:00
|
|
|
import "legacy-timeperiod"
|
2014-03-27 12:30:24 +01:00
|
|
|
|
2014-03-31 18:38:15 +02:00
|
|
|
display_name = "Icinga 2 8x5 TimePeriod"
|
2013-10-18 20:05:08 +02:00
|
|
|
ranges = {
|
2014-03-31 18:38:15 +02:00
|
|
|
"monday" = "09:00-17:00"
|
|
|
|
"tuesday" = "09:00-17:00"
|
|
|
|
"wednesday" = "09:00-17:00"
|
|
|
|
"thursday" = "09:00-17:00"
|
|
|
|
"friday" = "09:00-17:00"
|
2013-10-18 20:05:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-05 14:53:12 +02:00
|
|
|
Use the `notification_period` attribute to assign time periods to
|
|
|
|
`Notification` objects:
|
2013-10-18 20:05:08 +02:00
|
|
|
|
2014-04-05 14:53:12 +02:00
|
|
|
apply Notification "mail" to Host {
|
2014-03-31 18:38:15 +02:00
|
|
|
import "generic-notification"
|
2014-03-29 01:13:28 +01:00
|
|
|
|
2014-03-31 18:38:15 +02:00
|
|
|
notification_command = "mail-notification"
|
|
|
|
users = [ "icingaadmin" ]
|
2014-03-29 01:13:28 +01:00
|
|
|
notification_period = "workhours"
|
|
|
|
|
|
|
|
assign where host.name == "localhost"
|
2013-10-18 20:05:08 +02:00
|
|
|
}
|