]> granicus.if.org Git - icinga2/blob - doc/3.07-time-periods.md
Remove the 'Icinga' prefix for global constants.
[icinga2] / doc / 3.07-time-periods.md
1 ## <a id="timeperiods"></a> Time Periods
2
3 Time Periods define time ranges in Icinga where event actions are
4 triggered, for example if a service check is executed or not within
5 the `check_period` attribute. Or a notification should be sent to
6 users or not, filtered by the `notification_period` configuration
7 attribute for `Notification` and `User` objects.
8
9 > **Note**
10 >
11 > If you are familar with Icinga 1.x - these time period definitions
12 > are called `legacy timeperiods` in Icinga 2.
13 >
14 > An Icinga 2 legacy timeperiod requires the `ITL` provided template
15 >`legacy-timeperiod`.
16
17 The `TimePeriod` attribute `ranges` may contain multiple directives,
18 including weekdays, days of the month, and calendar dates.
19 These types may overlap/override other types in your ranges dictionary.
20
21 The descending order of precedence is as follows:
22
23 * Calendar date (2008-01-01)
24 * Specific month date (January 1st)
25 * Generic month date (Day 15)
26 * Offset weekday of specific month (2nd Tuesday in December)
27 * Offset weekday (3rd Monday)
28 * Normal weekday (Tuesday)
29
30 If you don't set any `check_period` or `notification_period` attribute
31 on your configuration objects Icinga 2 assumes `24x7` as time period
32 as shown below.
33
34     object TimePeriod "24x7" {
35       import "legacy-timeperiod"
36
37       display_name = "Icinga 2 24x7 TimePeriod"
38       ranges = {
39         "monday"    = "00:00-24:00"
40         "tuesday"   = "00:00-24:00"
41         "wednesday" = "00:00-24:00"
42         "thursday"  = "00:00-24:00"
43         "friday"    = "00:00-24:00"
44         "saturday"  = "00:00-24:00"
45         "sunday"    = "00:00-24:00"
46       }
47     }
48     
49 If your operation staff should only be notified during workhours
50 create a new timeperiod named `workhours` defining a work day with
51 09:00 to 17:00.
52
53     object TimePeriod "workhours" {
54       import "legacy-timeperiod"
55
56       display_name = "Icinga 2 8x5 TimePeriod"
57       ranges = {
58         "monday"    = "09:00-17:00"
59         "tuesday"   = "09:00-17:00"
60         "wednesday" = "09:00-17:00"
61         "thursday"  = "09:00-17:00"
62         "friday"    = "09:00-17:00"
63       }
64     }
65
66 Use the `notification_period` attribute to assign time periods to
67 `Notification` objects:
68
69     object Notification "mail" {
70       import "generic-notification"
71
72       host_name = "localhost"
73
74       notification_command = "mail-notification"
75       users = [ "icingaadmin" ]
76       notification_period = "workhours"
77     }