icinga2/doc/3.07-time-periods.md

78 lines
2.4 KiB
Markdown
Raw Normal View History

## <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.
object TimePeriod "24x7" {
import "legacy-timeperiod"
display_name = "Icinga 2 24x7 TimePeriod"
2013-10-18 20:05:08 +02:00
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"
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.
object TimePeriod "workhours" {
import "legacy-timeperiod"
display_name = "Icinga 2 8x5 TimePeriod"
2013-10-18 20:05:08 +02:00
ranges = {
"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
}
}
Assign the timeperiod as `notification_period` to the `Notification`
object then.
2014-03-29 01:13:28 +01:00
apply Notification "mail" {
import "generic-notification"
2014-03-29 01:13:28 +01: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
}