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