]> granicus.if.org Git - icinga2/blob - doc/04-configuration.md
Merge pull request #7445 from Icinga/bugfix/ddos-reconnect-7444
[icinga2] / doc / 04-configuration.md
1 # Configuration: First Steps <a id="configuration"></a>
2
3 This chapter provides an introduction into best practices for your Icinga 2 configuration.
4 The configuration files which are automatically created when installing the Icinga 2 packages
5 are a good way to start with Icinga 2.
6
7 The [Language Reference](17-language-reference.md#language-reference) chapter explains details
8 on value types (string, number, dictionaries, etc.) and the general configuration syntax.
9
10 ## Configuration Best Practice <a id="configuration-best-practice"></a>
11
12 If you are ready to configure additional hosts, services, notifications,
13 dependencies, etc., you should think about the requirements first and then
14 decide for a possible strategy.
15
16 There are many ways of creating Icinga 2 configuration objects:
17
18 * Manually with your preferred editor, for example vi(m), nano, notepad, etc.
19 * A configuration tool for Icinga 2 e.g. the [Icinga Director](https://github.com/Icinga/icingaweb2-module-director)
20 * Generated by a [configuration management tool](13-addons.md#configuration-tools) such as Puppet, Chef, Ansible, etc.
21 * A custom exporter script from your CMDB or inventory tool
22 * etc.
23
24 Find the best strategy for your own configuration and ask yourself the following questions:
25
26 * Do your hosts share a common group of services (for example linux hosts with disk, load, etc. checks)?
27 * Only a small set of users receives notifications and escalations for all hosts/services?
28
29 If you can at least answer one of these questions with yes, look for the
30 [apply rules](03-monitoring-basics.md#using-apply) logic instead of defining objects on a per
31 host and service basis.
32
33 * You are required to define specific configuration for each host/service?
34 * Does your configuration generation tool already know about the host-service-relationship?
35
36 Then you should look for the object specific configuration setting `host_name` etc. accordingly.
37
38 You decide on the "best" layout for configuration files and directories. Ensure that
39 the [icinga2.conf](04-configuration.md#icinga2-conf) configuration file includes them.
40
41 Consider these ideas:
42
43 * tree-based on locations, host groups, specific host attributes with sub levels of directories.
44 * flat `hosts.conf`, `services.conf`, etc. files for rule based configuration.
45 * generated configuration with one file per host and a global configuration for groups, users, etc.
46 * one big file generated from an external application (probably a bad idea for maintaining changes).
47 * your own.
48
49 In either way of choosing the right strategy you should additionally check the following:
50
51 * Are there any specific attributes describing the host/service you could set as `vars` custom variables?
52 You can later use them for applying assign/ignore rules, or export them into external interfaces.
53 * Put hosts into hostgroups, services into servicegroups and use these attributes for your apply rules.
54 * Use templates to store generic attributes for your objects and apply rules making your configuration more readable.
55 Details can be found in the [using templates](03-monitoring-basics.md#object-inheritance-using-templates) chapter.
56 * Apply rules may overlap. Keep a central place (for example, [services.conf](04-configuration.md#services-conf) or [notifications.conf](04-configuration.md#notifications-conf)) storing
57 the configuration instead of defining apply rules deep in your configuration tree.
58 * Every plugin used as check, notification or event command requires a `Command` definition.
59 Further details can be looked up in the [check commands](03-monitoring-basics.md#check-commands) chapter.
60
61 If you are planning to use a distributed monitoring setup with master, satellite and client installations
62 take the configuration location into account too. Everything configured on the master, synced to all other
63 nodes? Or any specific local configuration (e.g. health checks)?
64
65 There is a detailed chapter on [distributed monitoring scenarios](06-distributed-monitoring.md#distributed-monitoring-scenarios).
66 Please ensure to have read the [introduction](06-distributed-monitoring.md#distributed-monitoring) at first glance.
67
68 If you happen to have further questions, do not hesitate to join the
69 [community support channels](https://icinga.com/community/)
70 and ask community members for their experience and best practices.
71
72 ## Your Configuration <a id="your-configuration"></a>
73
74 If you prefer to organize your own local object tree, you can also remove
75 `include_recursive "conf.d"` from your icinga2.conf file.
76
77 Create a new configuration directory, e.g. `objects.d` and include it
78 in your icinga2.conf file.
79
80 ```
81 [root@icinga2-master1.localdomain /]# mkdir -p /etc/icinga2/objects.d
82
83 [root@icinga2-master1.localdomain /]# vim /etc/icinga2/icinga2.conf
84
85 /* Local object configuration on our master instance. */
86 include_recursive "objects.d"
87 ```
88
89 This approach is used by the [Icinga 2 Puppet module](https://github.com/Icinga/puppet-icinga2).
90
91 If you plan to setup a distributed setup with HA clusters and clients, please refer to [this chapter](#06-distributed-monitoring.md#distributed-monitoring-top-down)
92 for examples with `zones.d` as configuration directory.
93
94 ## Configuration Overview <a id="configuring-icinga2-overview"></a>
95
96 ### icinga2.conf <a id="icinga2-conf"></a>
97
98 An example configuration file is installed for you in `/etc/icinga2/icinga2.conf`.
99
100 Here's a brief description of the example configuration:
101
102 ```
103 /**
104 * Icinga 2 configuration file
105 * -- this is where you define settings for the Icinga application including
106 * which hosts/services to check.
107 *
108 * For an overview of all available configuration options please refer
109 * to the documentation that is distributed as part of Icinga 2.
110 */
111 ```
112
113 Icinga 2 supports [C/C++-style comments](17-language-reference.md#comments).
114
115 /**
116 * The constants.conf defines global constants.
117 */
118 include "constants.conf"
119
120 The `include` directive can be used to include other files.
121
122 ```
123 /**
124 * The zones.conf defines zones for a cluster setup.
125 * Not required for single instance setups.
126 */
127 include "zones.conf"
128 ```
129
130 The [Icinga Template Library](10-icinga-template-library.md#icinga-template-library) provides a set of common templates
131 and [CheckCommand](03-monitoring-basics.md#check-commands) definitions.
132
133 ```
134 /**
135 * The Icinga Template Library (ITL) provides a number of useful templates
136 * and command definitions.
137 * Common monitoring plugin command definitions are included separately.
138 */
139 include <itl>
140 include <plugins>
141 include <plugins-contrib>
142 include <manubulon>
143
144 /**
145 * This includes the Icinga 2 Windows plugins. These command definitions
146 * are required on a master node when a client is used as command endpoint.
147 */
148 include <windows-plugins>
149
150 /**
151 * This includes the NSClient++ check commands. These command definitions
152 * are required on a master node when a client is used as command endpoint.
153 */
154 include <nscp>
155
156 /**
157 * The features-available directory contains a number of configuration
158 * files for features which can be enabled and disabled using the
159 * icinga2 feature enable / icinga2 feature disable CLI commands.
160 * These commands work by creating and removing symbolic links in
161 * the features-enabled directory.
162 */
163 include "features-enabled/*.conf"
164 ```
165
166 This `include` directive takes care of including the configuration files for all
167 the features which have been enabled with `icinga2 feature enable`. See
168 [Enabling/Disabling Features](11-cli-commands.md#enable-features) for more details.
169
170 ```
171 /**
172 * Although in theory you could define all your objects in this file
173 * the preferred way is to create separate directories and files in the conf.d
174 * directory. Each of these files must have the file extension ".conf".
175 */
176 include_recursive "conf.d"
177 ```
178
179 You can put your own configuration files in the [conf.d](04-configuration.md#conf-d) directory. This
180 directive makes sure that all of your own configuration files are included.
181
182 ### constants.conf <a id="constants-conf"></a>
183
184 The `constants.conf` configuration file can be used to define global constants.
185
186 By default, you need to make sure to set these constants:
187
188 * The `PluginDir` constant must be set to the path where the [Monitoring Project plugins](02-installation.md#setting-up-check-plugins) are installed.
189 This constant is used by a number of
190 [built-in check command definitions](10-icinga-template-library.md#icinga-template-library).
191 * The `NodeName` constant defines your local node name. Should be set to FQDN which is the default
192 if not set. This constant is required for local host configuration, monitoring remote clients and
193 cluster setup.
194
195 Example:
196
197 ```
198 /* The directory which contains the plugins from the Monitoring Plugins project. */
199 const PluginDir = "/usr/lib64/nagios/plugins"
200
201 /* The directory which contains the Manubulon plugins.
202 * Check the documentation, chapter "SNMP Manubulon Plugin Check Commands", for details.
203 */
204 const ManubulonPluginDir = "/usr/lib64/nagios/plugins"
205
206 /* Our local instance name. By default this is the server's hostname as returned by `hostname --fqdn`.
207 * This should be the common name from the API certificate.
208 */
209 //const NodeName = "localhost"
210
211 /* Our local zone name. */
212 const ZoneName = NodeName
213
214 /* Secret key for remote node tickets */
215 const TicketSalt = ""
216 ```
217
218 The `ZoneName` and `TicketSalt` constants are required for remote client
219 and distributed setups only.
220
221 ### zones.conf <a id="zones-conf"></a>
222
223 This file can be used to specify the required [Zone](09-object-types.md#objecttype-zone)
224 and [Endpoint](09-object-types.md#objecttype-endpoint) configuration object for
225 [distributed monitoring](06-distributed-monitoring.md#distributed-monitoring).
226
227 By default the `NodeName` and `ZoneName` [constants](04-configuration.md#constants-conf) will be used.
228
229 It also contains several [global zones](06-distributed-monitoring.md#distributed-monitoring-global-zone-config-sync)
230 for distributed monitoring environments.
231
232 Please ensure to modify this configuration with real names i.e. use the FQDN
233 mentioned in [this chapter](06-distributed-monitoring.md#distributed-monitoring-conventions)
234 for your `Zone` and `Endpoint` object names.
235
236 ### The conf.d Directory <a id="conf-d"></a>
237
238 This directory contains **example configuration** which should help you get started
239 with monitoring the local host and its services. It is included in the
240 [icinga2.conf](04-configuration.md#icinga2-conf) configuration file by default.
241
242 It can be used as reference example for your own configuration strategy.
243 Just keep in mind to include the main directories in the
244 [icinga2.conf](04-configuration.md#icinga2-conf) file.
245
246 > **Note**
247 >
248 > You can remove the include directive in [icinga2.conf](04-configuration.md#icinga2-conf)
249 > if you prefer your own way of deploying Icinga 2 configuration.
250
251 Further details on configuration best practice and how to build your
252 own strategy is described in [this chapter](04-configuration.md#configuration-best-practice).
253
254 Available configuration files which are installed by default:
255
256 * [hosts.conf](04-configuration.md#hosts-conf)
257 * [services.conf](04-configuration.md#services-conf)
258 * [users.conf](04-configuration.md#users-conf)
259 * [notifications.conf](04-configuration.md#notifications-conf)
260 * [commands.conf](04-configuration.md#commands-conf)
261 * [groups.conf](04-configuration.md#groups-conf)
262 * [templates.conf](04-configuration.md#templates-conf)
263 * [downtimes.conf](04-configuration.md#downtimes-conf)
264 * [timeperiods.conf](04-configuration.md#timeperiods-conf)
265 * [api-users.conf](04-configuration.md#api-users-conf)
266 * [app.conf](04-configuration.md#app-conf)
267
268 #### hosts.conf <a id="hosts-conf"></a>
269
270 The `hosts.conf` file contains an example host based on your
271 `NodeName` setting in [constants.conf](04-configuration.md#constants-conf). You
272 can use global constants for your object names instead of string
273 values.
274
275 The `import` keyword is used to import the `generic-host` template which
276 takes care of setting up the host check command to `hostalive`. If you
277 require a different check command, you can override it in the object definition.
278
279 The `vars` attribute can be used to define custom variables which are available
280 for check and notification commands. Most of the [Plugin Check Commands](10-icinga-template-library.md#icinga-template-library)
281 in the Icinga Template Library require an `address` attribute.
282
283 The custom variable `os` is evaluated by the `linux-servers` group in
284 [groups.conf](04-configuration.md#groups-conf) making the local host a member.
285
286 The example host will show you how to:
287
288 * define http vhost attributes for the `http` service apply rule defined
289 in [services.conf](04-configuration.md#services-conf).
290 * define disks (all, specific `/`) and their attributes for the `disk`
291 service apply rule defined in [services.conf](04-configuration.md#services-conf).
292 * define notification types (`mail`) and set the groups attribute. This
293 will be used by notification apply rules in [notifications.conf](04-configuration.md#notifications-conf).
294
295 If you've installed [Icinga Web 2](02-installation.md#setting-up-icingaweb2), you can
296 uncomment the http vhost attributes and reload Icinga 2. The apply
297 rules in [services.conf](04-configuration.md#services-conf) will automatically
298 generate a new service checking the `/icingaweb2` URI using the `http`
299 check.
300
301 ```
302 /*
303 * Host definitions with object attributes
304 * used for apply rules for Service, Notification,
305 * Dependency and ScheduledDowntime objects.
306 *
307 * Tip: Use `icinga2 object list --type Host` to
308 * list all host objects after running
309 * configuration validation (`icinga2 daemon -C`).
310 */
311
312 /*
313  * This is an example host based on your
314  * local host's FQDN. Specify the NodeName
315  * constant in `constants.conf` or use your
316  * own description, e.g. "db-host-1".
317  */
318
319 object Host NodeName {
320   /* Import the default host template defined in `templates.conf`. */
321   import "generic-host"
322
323   /* Specify the address attributes for checks e.g. `ssh` or `http`. */
324   address = "127.0.0.1"
325   address6 = "::1"
326
327   /* Set custom variable `os` for hostgroup assignment in `groups.conf`. */
328   vars.os = "Linux"
329
330   /* Define http vhost attributes for service apply rules in `services.conf`. */
331   vars.http_vhosts["http"] = {
332     http_uri = "/"
333   }
334   /* Uncomment if you've sucessfully installed Icinga Web 2. */
335   //vars.http_vhosts["Icinga Web 2"] = {
336   //  http_uri = "/icingaweb2"
337   //}
338
339   /* Define disks and attributes for service apply rules in `services.conf`. */
340   vars.disks["disk"] = {
341     /* No parameters. */
342   }
343   vars.disks["disk /"] = {
344     disk_partitions = "/"
345   }
346
347   /* Define notification mail attributes for notification apply rules in `notifications.conf`. */
348   vars.notification["mail"] = {
349     /* The UserGroup `icingaadmins` is defined in `users.conf`. */
350     groups = [ "icingaadmins" ]
351   }
352 }
353 ```
354
355 This is only the host object definition. Now we'll need to make sure that this
356 host and your additional hosts are getting [services](04-configuration.md#services-conf) applied.
357
358 > **Tip**
359 >
360 > If you don't understand all the attributes and how to use [apply rules](17-language-reference.md#apply),
361 > don't worry -- the [monitoring basics](03-monitoring-basics.md#monitoring-basics) chapter will explain
362 > that in detail.
363
364 #### services.conf <a id="services-conf"></a>
365
366 These service [apply rules](17-language-reference.md#apply) will show you how to monitor
367 the local host, but also allow you to re-use or modify them for
368 your own requirements.
369
370 You should define all your service apply rules in `services.conf`
371 or any other central location keeping them organized.
372
373 By default, the local host will be monitored by the following services
374
375 Service(s)                                  | Applied on host(s)
376 --------------------------------------------|------------------------
377 `load`, `procs`, `swap`, `users`, `icinga`  | The `NodeName` host only.
378 `ping4`, `ping6`                            | All hosts with `address` resp. `address6` attribute.
379 `ssh`                                       | All hosts with `address` and `vars.os` set to `Linux`
380 `http`, optional: `Icinga Web 2`            | All hosts with custom variable `http_vhosts` defined as dictionary.
381 `disk`, `disk /`                            | All hosts with custom variable `disks` defined as dictionary.
382
383 The Debian packages also include an additional `apt` service check applied to the local host.
384
385 The command object `icinga` for the embedded health check is provided by the
386 [Icinga Template Library (ITL)](10-icinga-template-library.md#icinga-template-library) while `http_ip`, `ssh`, `load`, `processes`,
387 `users` and `disk` are all provided by the [Plugin Check Commands](10-icinga-template-library.md#icinga-template-library)
388 which we enabled earlier by including the `itl` and `plugins` configuration file.
389
390
391 Example `load` service apply rule:
392
393 ```
394 apply Service "load" {
395 import "generic-service"
396
397 check_command = "load"
398
399 /* Used by the ScheduledDowntime apply rule in `downtimes.conf`. */
400 vars.backup_downtime = "02:00-03:00"
401
402 assign where host.name == NodeName
403 }
404 ```
405
406 The `apply` keyword can be used to create new objects which are associated with
407 another group of objects. You can `import` existing templates, define (custom)
408 attributes.
409
410 The custom variable `backup_downtime` is defined to a specific timerange string.
411 This variable value will be used for applying a `ScheduledDowntime` object to
412 these services in [downtimes.conf](04-configuration.md#downtimes-conf).
413
414 In this example the `assign where` condition is a boolean expression which is
415 evaluated for all objects of type `Host` and a new service with name "load"
416 is created for each matching host. [Expression operators](17-language-reference.md#expression-operators)
417 may be used in `assign where` conditions.
418
419 Multiple `assign where` condition can be combined with `AND` using the `&&` operator
420 as shown in the `ssh` example:
421
422 ```
423 apply Service "ssh" {
424   import "generic-service"
425
426   check_command = "ssh"
427
428   assign where host.address && host.vars.os == "Linux"
429 }
430 ```
431
432 In this example, the service `ssh` is applied to all hosts having the `address`
433 attribute defined `AND` having the custom variable `os` set to the string
434 `Linux`.
435 You can modify this condition to match multiple expressions by combining `AND`
436 and `OR` using `&&` and `||` [operators](17-language-reference.md#expression-operators), for example
437 `assign where host.address && (vars.os == "Linux" || vars.os == "Windows")`.
438
439
440 A more advanced example is shown by the `http` and `disk` service apply
441 rules. While one `apply` rule for `ssh` will only create a service for matching
442 hosts, you can go one step further: Generate apply rules based on array items
443 or dictionary key-value pairs.
444
445 The idea is simple: Your host in [hosts.conf](04-configuration.md#hosts-conf) defines the
446 `disks` dictionary as custom variable in `vars`.
447
448 Remember the example from [hosts.conf](04-configuration.md#hosts-conf):
449
450 ```
451 ...
452   /* Define disks and attributes for service apply rules in `services.conf`. */
453   vars.disks["disk"] = {
454     /* No parameters. */
455   }
456   vars.disks["disk /"] = {
457     disk_partition = "/"
458   }
459 ...
460 ```
461
462 This dictionary contains multiple service names we want to monitor. `disk`
463 should just check all available disks, while `disk /` will pass an additional
464 parameter `disk_partition` to the check command.
465
466 You'll recognize that the naming is important -- that's the very same name
467 as it is passed from a service to a check command argument. Read about services
468 and passing check commands in [this chapter](03-monitoring-basics.md#command-passing-parameters).
469
470 Using `apply Service for` omits the service name, it will take the key stored in
471 the `disk` variable in `key => config` as new service object name.
472
473 The `for` keyword expects a loop definition, for example `key => value in dictionary`
474 as known from Perl and other scripting languages.
475
476 Once defined like this, the `apply` rule defined below will do the following:
477
478 * only match hosts with `host.vars.disks` defined through the `assign where` condition
479 * loop through all entries in the `host.vars.disks` dictionary. That's `disk` and `disk /` as keys.
480 * call `apply` on each, and set the service object name from the provided key
481 * inside apply, the `generic-service` template is imported
482 * defining the [disk](10-icinga-template-library.md#plugin-check-command-disk) check command requiring command arguments like `disk_partition`
483 * adding the `config` dictionary items to `vars`. Simply said, there's now `vars.disk_partition` defined for the
484 generated service
485
486 Configuration example:
487
488 ```
489 apply Service for (disk => config in host.vars.disks) {
490   import "generic-service"
491
492   check_command = "disk"
493
494   vars += config
495 }
496 ```
497
498 A similar example is used for the `http` services. That way you can make your
499 host the information provider for all apply rules. Define them once, and only
500 manage your hosts.
501
502 Look into [notifications.conf](04-configuration.md#notifications-conf) how this technique is used
503 for applying notifications to hosts and services using their type and user
504 attributes.
505
506 Don't forget to install the [check plugins](02-installation.md#setting-up-check-plugins) required by
507 the hosts and services and their check commands.
508
509 Further details on the monitoring configuration can be found in the
510 [monitoring basics](03-monitoring-basics.md#monitoring-basics) chapter.
511
512 #### users.conf <a id="users-conf"></a>
513
514 Defines the `icingaadmin` User and the `icingaadmins` UserGroup. The latter is used in
515 [hosts.conf](04-configuration.md#hosts-conf) for defining a custom host attribute later used in
516 [notifications.conf](04-configuration.md#notifications-conf) for notification apply rules.
517
518 ```
519 object User "icingaadmin" {
520   import "generic-user"
521
522   display_name = "Icinga 2 Admin"
523   groups = [ "icingaadmins" ]
524
525   email = "icinga@localhost"
526 }
527
528 object UserGroup "icingaadmins" {
529   display_name = "Icinga 2 Admin Group"
530 }
531 ```
532
533 #### notifications.conf <a id="notifications-conf"></a>
534
535 Notifications for check alerts are an integral part or your
536 Icinga 2 monitoring stack.
537
538 The examples in this file define two notification apply rules for hosts and services.
539 Both `apply` rules match on the same condition: They are only applied if the
540 nested dictionary attribute `notification.mail` is set.
541
542 Please note that the `to` keyword is important in [notification apply rules](03-monitoring-basics.md#using-apply-notifications)
543 defining whether these notifications are applies to hosts or services.
544 The `import` keyword imports the specific mail templates defined in [templates.conf](04-configuration.md#templates-conf).
545
546 The `interval` attribute is not explicitly set -- it [defaults to 30 minutes](09-object-types.md#objecttype-notification).
547
548 By setting the `user_groups` to the value provided by the
549 respective [host.vars.notification.mail](04-configuration.md#hosts-conf) attribute we'll
550 implicitely use the `icingaadmins` UserGroup defined in [users.conf](04-configuration.md#users-conf).
551
552 ```
553 apply Notification "mail-icingaadmin" to Host {
554   import "mail-host-notification"
555
556   user_groups = host.vars.notification.mail.groups
557   users = host.vars.notification.mail.users
558
559   assign where host.vars.notification.mail
560 }
561
562 apply Notification "mail-icingaadmin" to Service {
563   import "mail-service-notification"
564
565   user_groups = host.vars.notification.mail.groups
566   users = host.vars.notification.mail.users
567
568   assign where host.vars.notification.mail
569 }
570 ```
571
572 More details on defining notifications and their additional attributes such as
573 filters can be read in [this chapter](03-monitoring-basics.md#alert-notifications).
574
575 #### commands.conf <a id="commands-conf"></a>
576
577 This is the place where your own command configuration can be defined. By default
578 only the notification commands used by the notification templates defined in [templates.conf](04-configuration.md#templates-conf).
579
580 You can freely customize these notification commands, and adapt them for your needs.
581 Read more on that topic [here](03-monitoring-basics.md#notification-commands).
582
583 #### groups.conf <a id="groups-conf"></a>
584
585 The example host defined in [hosts.conf](hosts-conf) already has the
586 custom variable `os` set to `Linux` and is therefore automatically
587 a member of the host group `linux-servers`.
588
589 This is done by using the [group assign](17-language-reference.md#group-assign) expressions similar
590 to previously seen [apply rules](03-monitoring-basics.md#using-apply).
591
592 ```
593 object HostGroup "linux-servers" {
594   display_name = "Linux Servers"
595
596   assign where host.vars.os == "Linux"
597 }
598
599 object HostGroup "windows-servers" {
600   display_name = "Windows Servers"
601
602   assign where host.vars.os == "Windows"
603 }
604 ```
605
606 Service groups can be grouped together by similar pattern matches.
607 The [match function](18-library-reference.md#global-functions-match) expects a wildcard match string
608 and the attribute string to match with.
609
610 ```
611 object ServiceGroup "ping" {
612   display_name = "Ping Checks"
613
614   assign where match("ping*", service.name)
615 }
616
617 object ServiceGroup "http" {
618   display_name = "HTTP Checks"
619
620   assign where match("http*", service.check_command)
621 }
622
623 object ServiceGroup "disk" {
624   display_name = "Disk Checks"
625
626   assign where match("disk*", service.check_command)
627 }
628 ```
629
630 #### templates.conf <a id="templates-conf"></a>
631
632 Most of the example configuration objects use generic global templates by
633 default:
634
635 ```
636 template Host "generic-host" {
637   max_check_attempts = 5
638   check_interval = 1m
639   retry_interval = 30s
640
641   check_command = "hostalive"
642 }
643
644 template Service "generic-service" {
645   max_check_attempts = 3
646   check_interval = 1m
647   retry_interval = 30s
648 }
649 ```
650
651 The `hostalive` check command is part of the
652 [Plugin Check Commands](10-icinga-template-library.md#icinga-template-library).
653
654 ```
655 template Notification "mail-host-notification" {
656   command = "mail-host-notification"
657
658   states = [ Up, Down ]
659   types = [ Problem, Acknowledgement, Recovery, Custom,
660             FlappingStart, FlappingEnd,
661             DowntimeStart, DowntimeEnd, DowntimeRemoved ]
662
663   period = "24x7"
664 }
665
666 template Notification "mail-service-notification" {
667   command = "mail-service-notification"
668
669   states = [ OK, Warning, Critical, Unknown ]
670   types = [ Problem, Acknowledgement, Recovery, Custom,
671             FlappingStart, FlappingEnd,
672             DowntimeStart, DowntimeEnd, DowntimeRemoved ]
673
674   period = "24x7"
675 }
676 ```
677
678 More details on `Notification` object attributes can be found [here](09-object-types.md#objecttype-notification).
679
680
681 #### downtimes.conf <a id="downtimes-conf"></a>
682
683 The `load` service apply rule defined in [services.conf](04-configuration.md#services-conf) defines
684 the `backup_downtime` custom variable.
685
686 The ScheduledDowntime apply rule uses this attribute to define the default value
687 for the time ranges required for recurring downtime slots.
688
689 Learn more about downtimes in [this chapter](08-advanced-topics.md#downtimes).
690
691 ```
692 apply ScheduledDowntime "backup-downtime" to Service {
693   author = "icingaadmin"
694   comment = "Scheduled downtime for backup"
695
696   ranges = {
697     monday = service.vars.backup_downtime
698     tuesday = service.vars.backup_downtime
699     wednesday = service.vars.backup_downtime
700     thursday = service.vars.backup_downtime
701     friday = service.vars.backup_downtime
702     saturday = service.vars.backup_downtime
703     sunday = service.vars.backup_downtime
704   }
705
706   assign where service.vars.backup_downtime != ""
707 }
708 ```
709
710 #### timeperiods.conf <a id="timeperiods-conf"></a>
711
712 This file contains the default timeperiod definitions for `24x7`, `9to5`
713 and `never`. TimePeriod objects are referenced by `*period`
714 objects such as hosts, services or notifications.
715
716
717 #### api-users.conf <a id="api-users-conf"></a>
718
719 Provides the default [ApiUser](09-object-types.md#objecttype-apiuser) object
720 named "root" for the [API authentication](12-icinga2-api.md#icinga2-api-authentication).
721
722 #### app.conf <a id="app-conf"></a>
723
724 Provides the default [IcingaApplication](09-object-types.md#objecttype-icingaapplication)
725 object named "app" for additional settings such as disabling notifications
726 globally, etc.