]> granicus.if.org Git - icinga2/blob - doc/6-object-types.md
ea8ce9e03b3a7d6a76a4ef0a9e5e44f50c20bdee
[icinga2] / doc / 6-object-types.md
1 # <a id="object-types"></a> Object Types
2
3 This chapter provides an overview of all available object types which can be
4 instantiated using the `object` keyword.
5
6 Additional details on configuration and runtime attributes and their
7 description are explained as well.
8
9 ## <a id="objecttype-apilistener"></a> ApiListener
10
11 ApiListener objects are used for distributed monitoring setups
12 and API usage specifying the certificate files used for ssl
13 authorization and additional restrictions.
14
15 The `NodeName` constant must be defined in [constants.conf](4-configuring-icinga-2.md#constants-conf).
16
17 Example:
18
19     object ApiListener "api" {
20       cert_path = SysconfDir + "/icinga2/pki/" + NodeName + ".crt"
21       key_path = SysconfDir + "/icinga2/pki/" + NodeName + ".key"
22       ca_path = SysconfDir + "/icinga2/pki/ca.crt"
23     }
24
25
26 Configuration Attributes:
27
28   Name                      |Description
29   --------------------------|--------------------------
30   cert\_path                |**Required.** Path to the public key.
31   key\_path                 |**Required.** Path to the private key.
32   ca\_path                  |**Required.** Path to the CA certificate file.
33   crl\_path                 |**Optional.** Path to the CRL file.
34   bind\_host                |**Optional.** The IP address the api listener should be bound to. Defaults to `0.0.0.0`.
35   bind\_port                |**Optional.** The port the api listener should be bound to. Defaults to `5665`.
36   accept\_config            |**Optional.** Accept zone configuration. Defaults to `false`.
37   accept\_commands          |**Optional.** Accept remote commands. Defaults to `false`.
38
39 ## <a id="objecttype-apiuser"></a> ApiUser
40
41 ApiUser objects are used for authentication against the Icinga 2 API.
42
43 Example:
44
45     object ApiUser "root" {
46       password = "mysecretapipassword"
47       permissions = [ "*" ]
48     }
49
50
51 Configuration Attributes:
52
53   Name                      |Description
54   --------------------------|--------------------------
55   password                  |**Optional.** Password string.
56   client\_cn                |**Optional.** Client Common Name (CN).
57   permissions               |**Required.** Array of permissions. Either as string or dictionary with the keys `permission` and `filter`. The latter must be specified as function.
58
59 Available permissions are described in the [API permissions](9-icinga2-api.md#icinga2-api-permissions)
60 chapter.
61
62 ## <a id="objecttype-checkcommand"></a> CheckCommand
63
64 A check command definition. Additional default command custom attributes can be
65 defined here.
66
67 Example:
68
69     object CheckCommand "check_http" {
70       import "plugin-check-command"
71
72       command = [ PluginDir + "/check_http" ]
73
74       arguments = {
75         "-H" = "$http_vhost$"
76         "-I" = "$http_address$"
77         "-u" = "$http_uri$"
78         "-p" = "$http_port$"
79         "-S" = {
80           set_if = "$http_ssl$"
81         }
82         "--sni" = {
83           set_if = "$http_sni$"
84         }
85         "-a" = {
86           value = "$http_auth_pair$"
87           description = "Username:password on sites with basic authentication"
88         }
89         "--no-body" = {
90           set_if = "$http_ignore_body$"
91         }
92         "-r" = "$http_expect_body_regex$"
93         "-w" = "$http_warn_time$"
94         "-c" = "$http_critical_time$"
95         "-e" = "$http_expect$"
96       }
97
98       vars.http_address = "$address$"
99       vars.http_ssl = false
100       vars.http_sni = false
101     }
102
103
104 Configuration Attributes:
105
106   Name            |Description
107   ----------------|----------------
108   execute         |**Required.** The "execute" script method takes care of executing the check. In virtually all cases you should import the "plugin-check-command" template to take care of this setting.
109   command         |**Required.** The command. This can either be an array of individual command arguments. Alternatively a string can be specified in which case the shell interpreter (usually /bin/sh) takes care of parsing the command. When using the "arguments" attribute this must be an array. Can be specified as function for advanced implementations.
110   env             |**Optional.** A dictionary of macros which should be exported as environment variables prior to executing the command.
111   vars            |**Optional.** A dictionary containing custom attributes that are specific to this command.
112   timeout         |**Optional.** The command timeout in seconds. Defaults to 60 seconds.
113   arguments       |**Optional.** A dictionary of command arguments.
114
115
116 ### <a id="objecttype-checkcommand-arguments"></a> CheckCommand Arguments
117
118 Command arguments can be defined as key-value-pairs in the `arguments`
119 dictionary. If the argument requires additional configuration for example
120 a `description` attribute or an optional condition, the value can be defined
121 as dictionary specifying additional options.
122
123 Service:
124
125     vars.x_val = "My command argument value."
126     vars.have_x = "true"
127
128 CheckCommand:
129
130     arguments = {
131       "-X" = {
132         value = "$x_val$"
133         key = "-Xnew"       /* optional, set a new key identifier */
134         description = "My plugin requires this argument for doing X."
135         required = false    /* optional, no error if not set */
136         skip_key = false    /* always use "-X <value>" */
137         set_if = "$have_x$" /* only set if variable defined and resolves to a numeric value. String values are not supported */
138         order = -1          /* first position */
139         repeat_key = true   /* if `value` is an array, repeat the key as parameter: ... 'key' 'value[0]' 'key' 'value[1]' 'key' 'value[2]' ... */
140       }
141       "-Y" = {
142         value = "$y_val$"
143         description = "My plugin requires this argument for doing Y."
144         required = false    /* optional, no error if not set */
145         skip_key = true     /* don't prefix "-Y" only use "<value>" */
146         set_if = "$have_y$" /* only set if variable defined and resolves to a numeric value. String values are not supported */
147         order = 0           /* second position */
148         repeat_key = false  /* if `value` is an array, do not repeat the key as parameter: ... 'key' 'value[0]' 'value[1]' 'value[2]' ... */
149       }
150     }
151
152   Option      | Description
153   ------------|--------------
154   value       | Optional argument value set by a macro string or a function call.
155   key         | Optional argument key overriding the key identifier.
156   description | Optional argument description.
157   required    | Required argument. Execution error if not set. Defaults to false (optional).
158   skip_key    | Use the value as argument and skip the key.
159   set_if      | Argument is added if the macro resolves to a defined numeric or boolean value. String values are not supported. Function calls returning a value are supported too.
160   order       | Set if multiple arguments require a defined argument order.
161   repeat_key  | If the argument value is an array, repeat the argument key, or not. Defaults to true (repeat).
162
163 Argument order:
164
165     `..., -3, -2, -1, <un-ordered keys>, 1, 2, 3, ...`
166
167 Argument array `repeat_key = true`:
168
169     `'key' 'value[0]' 'key' 'value[1]' 'key' 'value[2]'`
170
171 Argument array `repeat_key = false`:
172
173     `'key' 'value[0]' 'value[1]' 'value[2]'`
174
175 ## <a id="objecttype-checkcomponent"></a> CheckerComponent
176
177 The checker component is responsible for scheduling active checks. There are no configurable options.
178
179 Example:
180
181     library "checker"
182
183     object CheckerComponent "checker" { }
184
185 ## <a id="objecttype-checkresultreader"></a> CheckResultReader
186
187 Reads Icinga 1.x check results from a directory. This functionality is provided
188 to help existing Icinga 1.x users and might be useful for certain cluster
189 scenarios.
190
191 Example:
192
193     library "compat"
194
195     object CheckResultReader "reader" {
196       spool_dir = "/data/check-results"
197     }
198
199 Configuration Attributes:
200
201   Name            |Description
202   ----------------|----------------
203   spool\_dir      |**Optional.** The directory which contains the check result files. Defaults to LocalStateDir + "/lib/icinga2/spool/checkresults/".
204
205 ## <a id="objecttype-comment"></a> Comment
206
207 Comments created at runtime are represented as objects.
208
209 Example:
210
211     object Comment "localhost!my-comment" {
212       host_name = "localhost"
213       author = "icingaadmin"
214       text = "This is a comment."
215     }
216
217 Configuration Attributes:
218
219   Name            |Description
220   ----------------|----------------
221   host_name       | **Required.** The name of the host this comment belongs to.
222   service_name    | **Optional.** The short name of the service this comment belongs to. If omitted this comment object is treated as host comment.
223   author          | **Required.** The author's name.
224   text            | **Required.** The comment text.
225   entry_time      | **Optional.** The unix timestamp when this comment was added.
226   entry_type      | **Optional.** The comment type (`User` = 1, `Downtime` = 2, `Flapping` = 3, `Acknowledgement` = 4).
227   expire_time     | **Optional.** The comment's expire time as unix timestamp.
228
229 ## <a id="objecttype-compatlogger"></a> CompatLogger
230
231 Writes log files in a format that's compatible with Icinga 1.x.
232
233 Example:
234
235     library "compat"
236
237     object CompatLogger "my-log" {
238       log_dir = "/var/log/icinga2/compat"
239       rotation_method = "HOURLY"
240     }
241
242 Configuration Attributes:
243
244   Name            |Description
245   ----------------|----------------
246   log\_dir        |**Optional.** Path to the compat log directory. Defaults to LocalStateDir + "/log/icinga2/compat".
247   rotation\_method|**Optional.** Specifies when to rotate log files. Can be one of "HOURLY", "DAILY", "WEEKLY" or "MONTHLY". Defaults to "HOURLY".
248
249
250
251 ## <a id="objecttype-dependency"></a> Dependency
252
253 Dependency objects are used to specify dependencies between hosts and services. Dependencies
254 can be defined as Host-to-Host, Service-to-Service, Service-to-Host, or Host-to-Service
255 relations.
256
257 > **Best Practice**
258 >
259 > Rather than creating a `Dependency` object for a specific host or service it is usually easier
260 > to just create a `Dependency` template and use the `apply` keyword to assign the
261 > dependency to a number of hosts or services. Use the `to` keyword to set the specific target
262 > type for `Host` or `Service`.
263 > Check the [dependencies](3-monitoring-basics.md#dependencies) chapter for detailed examples.
264
265 Service-to-Service Example:
266
267     object Dependency "webserver-internet" {
268       parent_host_name = "internet"
269       parent_service_name = "ping4"
270
271       child_host_name = "webserver"
272       child_service_name = "ping4"
273
274       states = [ OK, Warning ]
275
276       disable_checks = true
277     }
278
279 Host-to-Host Example:
280
281     object Dependency "webserver-internet" {
282       parent_host_name = "internet"
283
284       child_host_name = "webserver"
285
286       states = [ Up ]
287
288       disable_checks = true
289     }
290
291 Configuration Attributes:
292
293   Name                  |Description
294   ----------------------|----------------
295   parent_host_name      |**Required.** The parent host.
296   parent_service_name   |**Optional.** The parent service. If omitted this dependency object is treated as host dependency.
297   child_host_name       |**Required.** The child host.
298   child_service_name    |**Optional.** The child service. If omitted this dependency object is treated as host dependency.
299   disable_checks        |**Optional.** Whether to disable checks when this dependency fails. Defaults to false.
300   disable_notifications |**Optional.** Whether to disable notifications when this dependency fails. Defaults to true.
301   ignore_soft_states    |**Optional.** Whether to ignore soft states for the reachability calculation. Defaults to true.
302   period                |**Optional.** Time period during which this dependency is enabled.
303   states                |**Optional.** A list of state filters when this dependency should be OK. Defaults to [ OK, Warning ] for services and [ Up ] for hosts.
304
305 Available state filters:
306
307     OK
308     Warning
309     Critical
310     Unknown
311     Up
312     Down
313
314 When using [apply rules](3-monitoring-basics.md#using-apply) for dependencies, you can leave out certain attributes which will be
315 automatically determined by Icinga 2.
316
317 Service-to-Host Dependency Example:
318
319     apply Dependency "internet" to Service {
320       parent_host_name = "dsl-router"
321       disable_checks = true
322
323       assign where host.name != "dsl-router"
324     }
325
326 This example sets all service objects matching the assign condition into a dependency relation to
327 the parent host object `dsl-router` as implicit child services.
328
329 Service-to-Service-on-the-same-Host Dependency Example:
330
331     apply Dependency "disable-nrpe-checks" to Service {
332       parent_service_name = "nrpe-health"
333
334       assign where service.check_command == "nrpe"
335       ignore where service.name == "nrpe-health"
336     }
337
338 This example omits the `parent_host_name` attribute and Icinga 2 automatically sets its value to the name of the
339 host object matched by the apply rule condition. All services where apply matches are made implicit child services
340 in this dependency relation.
341
342
343 Dependency objects have composite names, i.e. their names are based on the `child_host_name` and `child_service_name` attributes and the
344 name you specified. This means you can define more than one object with the same (short) name as long as one of the `child_host_name` and
345 `child_service_name` attributes has a different value.
346
347 ## <a id="objecttype-downtime"></a> Downtime
348
349 Downtimes created at runtime are represented as objects.
350
351 Example:
352
353     object Downtime "localhost!my-downtime" {
354       host_name = "localhost"
355       author = "icingaadmin"
356       text = "This is a comment."
357     }
358
359 Configuration Attributes:
360
361   Name            |Description
362   ----------------|----------------
363   host_name       | **Required.** The name of the host this comment belongs to.
364   service_name    | **Optional.** The short name of the service this comment belongs to. If omitted this comment object is treated as host comment.
365   author          | **Required.** The author's name.
366   comment         | **Required.** The comment text.
367   start_time      | **Required.** The start time as unix timestamp.
368   end_time        | **Required.** The end time as unix timestamp.
369   duration        | **Required.** The duration as number.
370   entry_time      | **Optional.** The unix timestamp when this downtime was added.
371   fixed           | **Optional.** Whether the downtime is fixed (true) or flexible (false). Defaults to flexible. Details in the [advanced topics chapter](5-advanced-topics.md#fixed-flexible-downtimes).
372   triggers        | **Optional.** List of downtimes which should be triggered by this downtime.
373
374 Runtime Attributes:
375
376   Name            |Description
377   ----------------|----------------
378   trigger_time    | The unix timestamp when this downtime was triggered.
379   triggered_by    | The name of the downtime this downtime was triggered by.
380
381
382
383 ## <a id="objecttype-endpoint"></a> Endpoint
384
385 Endpoint objects are used to specify connection information for remote
386 Icinga 2 instances.
387
388 Example:
389
390     object Endpoint "icinga2b" {
391       host = "192.168.5.46"
392       port = 5665
393     }
394
395 Configuration Attributes:
396
397   Name            |Description
398   ----------------|----------------
399   host            |**Optional.** The hostname/IP address of the remote Icinga 2 instance.
400   port            |**Optional.** The service name/port of the remote Icinga 2 instance. Defaults to `5665`.
401   log_duration    |**Optional.** Duration for keeping replay logs on connection loss. Defaults to `1d`.
402
403
404 ## <a id="objecttype-eventcommand"></a> EventCommand
405
406 An event command definition.
407
408 Example:
409
410     object EventCommand "restart-httpd-event" {
411       import "plugin-event-command"
412
413       command = "/opt/bin/restart-httpd.sh"
414     }
415
416
417 Configuration Attributes:
418
419   Name            |Description
420   ----------------|----------------
421   execute         |**Required.** The "execute" script method takes care of executing the event handler. In virtually all cases you should import the "plugin-event-command" template to take care of this setting.
422   command         |**Required.** The command. This can either be an array of individual command arguments. Alternatively a string can be specified in which case the shell interpreter (usually /bin/sh) takes care of parsing the command.
423   env             |**Optional.** A dictionary of macros which should be exported as environment variables prior to executing the command.
424   vars            |**Optional.** A dictionary containing custom attributes that are specific to this command.
425   timeout         |**Optional.** The command timeout in seconds. Defaults to 60 seconds.
426   arguments       |**Optional.** A dictionary of command arguments.
427
428 Command arguments can be used the same way as for [CheckCommand objects](6-object-types.md#objecttype-checkcommand-arguments).
429
430
431 ## <a id="objecttype-externalcommandlistener"></a> ExternalCommandListener
432
433 Implements the Icinga 1.x command pipe which can be used to send commands to Icinga.
434
435 Example:
436
437     library "compat"
438
439     object ExternalCommandListener "external" {
440         command_path = "/var/run/icinga2/cmd/icinga2.cmd"
441     }
442
443 Configuration Attributes:
444
445   Name            |Description
446   ----------------|----------------
447   command\_path   |**Optional.** Path to the command pipe. Defaults to RunDir + "/icinga2/cmd/icinga2.cmd".
448
449
450
451 ## <a id="objecttype-filelogger"></a> FileLogger
452
453 Specifies Icinga 2 logging to a file.
454
455 Example:
456
457     object FileLogger "debug-file" {
458       severity = "debug"
459       path = "/var/log/icinga2/debug.log"
460     }
461
462 Configuration Attributes:
463
464   Name            |Description
465   ----------------|----------------
466   path            |**Required.** The log path.
467   severity        |**Optional.** The minimum severity for this log. Can be "debug", "notice", "information", "warning" or "critical". Defaults to "information".
468
469
470 ## <a id="objecttype-gelfwriter"></a> GelfWriter
471
472 Writes event log entries to a defined GELF receiver host (Graylog2, Logstash).
473
474 Example:
475
476     library "perfdata"
477
478     object GelfWriter "gelf" {
479       host = "127.0.0.1"
480       port = 12201
481     }
482
483 Configuration Attributes:
484
485   Name                  |Description
486   ----------------------|----------------------
487   host                  |**Optional.** GELF receiver host address. Defaults to '127.0.0.1'.
488   port                  |**Optional.** GELF receiver port. Defaults to `12201`.
489   source                |**Optional.** Source name for this instance. Defaults to `icinga2`.
490
491
492 ## <a id="objecttype-graphitewriter"></a> GraphiteWriter
493
494 Writes check result metrics and performance data to a defined
495 Graphite Carbon host.
496
497 Example:
498
499     library "perfdata"
500
501     object GraphiteWriter "graphite" {
502       host = "127.0.0.1"
503       port = 2003
504     }
505
506 Configuration Attributes:
507
508   Name                  |Description
509   ----------------------|----------------------
510   host                  |**Optional.** Graphite Carbon host address. Defaults to '127.0.0.1'.
511   port                  |**Optional.** Graphite Carbon port. Defaults to 2003.
512   host_name_template    |**Optional.** Metric prefix for host name. Defaults to "icinga2.$host.name$.host.$host.check_command$".
513   service_name_template |**Optional.** Metric prefix for service name. Defaults to "icinga2.$host.name$.services.$service.name$.$service.check_command$".
514   enable_send_thresholds | **Optional.** Send additional threshold metrics. Defaults to `false`.
515   enable_send_metadata  | **Optional.** Send additional metadata metrics. Defaults to `false`.
516   enable_legacy_mode    | **Optional.** Enable legacy mode for schema < 2.4. **Note**: This will be removed in future versions.
517
518 Additional usage examples can be found [here](15-features.md#graphite-carbon-cache-writer).
519
520
521
522 ## <a id="objecttype-host"></a> Host
523
524 A host.
525
526 Example:
527
528     object Host NodeName {
529       display_name = "Local host on this node"
530       address = "127.0.0.1"
531       address6 = "::1"
532
533       groups = [ "all-hosts" ]
534
535       check_command = "hostalive"
536     }
537
538 Configuration Attributes:
539
540   Name            |Description
541   ----------------|----------------
542   display_name    |**Optional.** A short description of the host (e.g. displayed by external interfaces instead of the name if set).
543   address         |**Optional.** The host's address. Available as command runtime macro `$address$` if set.
544   address6        |**Optional.** The host's address. Available as command runtime macro `$address6$` if set.
545   groups          |**Optional.** A list of host groups this host belongs to.
546   vars            |**Optional.** A dictionary containing custom attributes that are specific to this host.
547   check\_command  |**Required.** The name of the check command.
548   max\_check\_attempts|**Optional.** The number of times a host is re-checked before changing into a hard state. Defaults to 3.
549   check\_period   |**Optional.** The name of a time period which determines when this host should be checked. Not set by default.
550   check\_interval |**Optional.** The check interval (in seconds). This interval is used for checks when the host is in a `HARD` state. Defaults to 5 minutes.
551   retry\_interval |**Optional.** The retry interval (in seconds). This interval is used for checks when the host is in a `SOFT` state. Defaults to 1 minute.
552   enable\_notifications|**Optional.** Whether notifications are enabled. Defaults to true.
553   enable\_active\_checks|**Optional.** Whether active checks are enabled. Defaults to true.
554   enable\_passive\_checks|**Optional.** Whether passive checks are enabled. Defaults to true.
555   enable\_event\_handler|**Optional.** Enables event handlers for this host. Defaults to true.
556   enable\_flapping|**Optional.** Whether flap detection is enabled. Defaults to false.
557   enable\_perfdata|**Optional.** Whether performance data processing is enabled. Defaults to true.
558   event\_command  |**Optional.** The name of an event command that should be executed every time the host's state changes or the host is in a `SOFT` state.
559   flapping\_threshold|**Optional.** The flapping threshold in percent when a host is considered to be flapping.
560   volatile        |**Optional.** The volatile setting enables always `HARD` state types if `NOT-OK` state changes occur.
561   zone            |**Optional.** The zone this object is a member of.
562   command\_endpoint|**Optional.** The endpoint where commands are executed on.
563   notes           |**Optional.** Notes for the host.
564   notes\_url      |**Optional.** Url for notes for the host (for example, in notification commands).
565   action\_url     |**Optional.** Url for actions for the host (for example, an external graphing tool).
566   icon\_image     |**Optional.** Icon image for the host. Used by external interfaces only.
567   icon\_image\_alt|**Optional.** Icon image description for the host. Used by external interface only.
568
569 > **Best Practice**
570 >
571 > The `address` and `address6` attributes are required for running commands using
572 > the `$address$` and `$address6$` runtime macros.
573
574 Runtime Attributes:
575
576   Name                      | Type          | Description
577   --------------------------|---------------|-----------------
578   next\_check               | Number        | When the next check occurs (as a UNIX timestamp).
579   check\_attempt            | Number        | The current check attempt number.
580   state\_type               | Number        | The current state type (0 = SOFT, 1 = HARD).
581   last\_state\_type         | Number        | The previous state type (0 = SOFT, 1 = HARD).
582   last\_reachable           | Boolean       | Whether the host was reachable when the last check occurred.
583   last\_check\_result       | CheckResult   | The current check result.
584   last\_state\_change       | Number        | When the last state change occurred (as a UNIX timestamp).
585   last\_hard\_state\_change | Number        | When the last hard state change occurred (as a UNIX timestamp).
586   last\_in\_downtime        | Boolean       | Whether the host was in a downtime when the last check occurred.
587   acknowledgement           | Number        | The acknowledgement type (0 = NONE, 1 = NORMAL, 2 = STICKY).
588   acknowledgement_expiry    | Number        | When the acknowledgement expires (as a UNIX timestamp; 0 = no expiry).
589   comments                  | Dictionary    | The comments for this host.
590   downtimes                 | Dictionary    | The downtimes for this host.
591   state                     | Number        | The current state (0 = UP, 1 = DOWN).
592   last\_state               | Number        | The previous state (0 = UP, 1 = DOWN).
593   last\_hard\_state         | Number        | The last hard state (0 = UP, 1 = DOWN).
594
595
596
597 ## <a id="objecttype-hostgroup"></a> HostGroup
598
599 A group of hosts.
600
601 > **Best Practice**
602 >
603 > Assign host group members using the [group assign](18-language-reference.md#group-assign) rules.
604
605 Example:
606
607     object HostGroup "my-hosts" {
608       display_name = "My hosts"
609     }
610
611 Configuration Attributes:
612
613   Name            |Description
614   ----------------|----------------
615   display_name    |**Optional.** A short description of the host group.
616   groups          |**Optional.** An array of nested group names.
617
618 ## <a id="objecttype-icingaapplication"></a> IcingaApplication
619
620 The IcingaApplication object is required to start Icinga 2.
621 The object name must be `app`. If the object configuration
622 is missing Icinga 2 will automatically create an IcingaApplication
623 object.
624
625 Example:
626
627     object IcingaApplication "app" {
628       enable_perfdata = false
629     }
630
631 Configuration Attributes:
632
633   Name                  |Description
634   ----------------------|--------------------------
635   enable_notifications  |**Optional.** Whether notifications are globally enabled. Defaults to true.
636   enable_event_handlers |**Optional.** Whether event handlers are globally enabled. Defaults to true.
637   enable_flapping       |**Optional.** Whether flap detection is globally enabled. Defaults to true.
638   enable_host_checks    |**Optional.** Whether active host checks are globally enabled. Defaults to true.
639   enable_service_checks |**Optional.** Whether active service checks are globally enabled. Defaults to true.
640   enable_perfdata       |**Optional.** Whether performance data processing is globally enabled. Defaults to true.
641   vars                  |**Optional.** A dictionary containing custom attributes that are available globally.
642
643 ## <a id="objecttype-icingastatuswriter"></a> IcingaStatusWriter
644
645 > **Note**
646 >
647 > This feature was deprecated in 2.4 and will be removed in future releases.
648
649 The IcingaStatusWriter feature periodically dumps the current status
650 and performance data from Icinga 2 and all registered features into
651 a defined JSON file.
652
653 Example:
654
655     object IcingaStatusWriter "status" {
656       status_path = LocalStateDir + "/cache/icinga2/status.json"
657       update_interval = 15s
658     }
659
660 Configuration Attributes:
661
662   Name                      |Description
663   --------------------------|--------------------------
664   status\_path              |**Optional.** Path to cluster status file. Defaults to LocalStateDir + "/cache/icinga2/status.json"
665   update\_interval          |**Optional.** The interval in which the status files are updated. Defaults to 15 seconds.
666
667
668 ## <a id="objecttype-idomysqlconnection"></a> IdoMySqlConnection
669
670 IDO database adapter for MySQL.
671
672 Example:
673
674     library "db_ido_mysql"
675
676     object IdoMysqlConnection "mysql-ido" {
677       host = "127.0.0.1"
678       port = 3306
679       user = "icinga"
680       password = "icinga"
681       database = "icinga"
682       table_prefix = "icinga_"
683       instance_name = "icinga2"
684       instance_description = "icinga2 instance"
685
686       cleanup = {
687         downtimehistory_age = 48h
688         logentries_age = 31d
689       }
690
691       categories = DbCatConfig | DbCatState
692     }
693
694 Configuration Attributes:
695
696   Name            |Description
697   ----------------|----------------
698   host            |**Optional.** MySQL database host address. Defaults to "localhost".
699   port            |**Optional.** MySQL database port. Defaults to 3306.
700   socket_path     |**Optional.** MySQL socket path.
701   user            |**Optional.** MySQL database user with read/write permission to the icinga database. Defaults to "icinga".
702   password        |**Optional.** MySQL database user's password. Defaults to "icinga".
703   database        |**Optional.** MySQL database name. Defaults to "icinga".
704   table\_prefix   |**Optional.** MySQL database table prefix. Defaults to "icinga\_".
705   instance\_name  |**Optional.** Unique identifier for the local Icinga 2 instance. Defaults to "default".
706   instance\_description|**Optional.** Description for the Icinga 2 instance.
707   enable_ha       |**Optional.** Enable the high availability functionality. Only valid in a [cluster setup](13-distributed-monitoring-ha.md#high-availability-db-ido). Defaults to "true".
708   failover_timeout | **Optional.** Set the failover timeout in a [HA cluster](13-distributed-monitoring-ha.md#high-availability-db-ido). Must not be lower than 60s. Defaults to "60s".
709   cleanup         |**Optional.** Dictionary with items for historical table cleanup.
710   categories      |**Optional.** The types of information that should be written to the database.
711
712 Cleanup Items:
713
714   Name            | Description
715   ----------------|----------------
716   acknowledgements_age |**Optional.** Max age for acknowledgements table rows (entry_time). Defaults to 0 (never).
717   commenthistory_age |**Optional.** Max age for commenthistory table rows (entry_time). Defaults to 0 (never).
718   contactnotifications_age |**Optional.** Max age for contactnotifications table rows (start_time). Defaults to 0 (never).
719   contactnotificationmethods_age |**Optional.** Max age for contactnotificationmethods table rows (start_time). Defaults to 0 (never).
720   downtimehistory_age |**Optional.** Max age for downtimehistory table rows (entry_time). Defaults to 0 (never).
721   eventhandlers_age |**Optional.** Max age for eventhandlers table rows (start_time). Defaults to 0 (never).
722   externalcommands_age |**Optional.** Max age for externalcommands table rows (entry_time). Defaults to 0 (never).
723   flappinghistory_age |**Optional.** Max age for flappinghistory table rows (event_time). Defaults to 0 (never).
724   hostchecks_age |**Optional.** Max age for hostalives table rows (start_time). Defaults to 0 (never).
725   logentries_age |**Optional.** Max age for logentries table rows (logentry_time). Defaults to 0 (never).
726   notifications_age |**Optional.** Max age for notifications table rows (start_time). Defaults to 0 (never).
727   processevents_age |**Optional.** Max age for processevents table rows (event_time). Defaults to 0 (never).
728   statehistory_age |**Optional.** Max age for statehistory table rows (state_time). Defaults to 0 (never).
729   servicechecks_age |**Optional.** Max age for servicechecks table rows (start_time). Defaults to 0 (never).
730   systemcommands_age |**Optional.** Max age for systemcommands table rows (start_time). Defaults to 0 (never).
731
732 Data Categories:
733
734   Name                 | Description            | Required by
735   ---------------------|------------------------|--------------------
736   DbCatConfig          | Configuration data     | Icinga Web/Reporting
737   DbCatState           | Current state data     | Icinga Web/Reporting
738   DbCatAcknowledgement | Acknowledgements       | Icinga Web/Reporting
739   DbCatComment         | Comments               | Icinga Web/Reporting
740   DbCatDowntime        | Downtimes              | Icinga Web/Reporting
741   DbCatEventHandler    | Event handler data     | Icinga Web/Reporting
742   DbCatExternalCommand | External commands      | Icinga Web/Reporting
743   DbCatFlapping        | Flap detection data    | Icinga Web/Reporting
744   DbCatCheck           | Check results          | --
745   DbCatLog             | Log messages           | Icinga Web/Reporting
746   DbCatNotification    | Notifications          | Icinga Web/Reporting
747   DbCatProgramStatus   | Program status data    | Icinga Web/Reporting
748   DbCatRetention       | Retention data         | Icinga Web/Reporting
749   DbCatStateHistory    | Historical state data  | Icinga Web/Reporting
750
751 Multiple categories can be combined using the `|` operator. In addition to
752 the category flags listed above the `DbCatEverything` flag may be used as
753 a shortcut for listing all flags.
754
755 External interfaces like Icinga Web require everything except `DbCatCheck`
756 which is the default value if `categories` is not set.
757
758 ## <a id="objecttype-idopgsqlconnection"></a> IdoPgSqlConnection
759
760 IDO database adapter for PostgreSQL.
761
762 Example:
763
764     library "db_ido_pgsql"
765
766     object IdoMysqlConnection "pgsql-ido" {
767       host = "127.0.0.1"
768       port = 5432
769       user = "icinga"
770       password = "icinga"
771       database = "icinga"
772       table_prefix = "icinga_"
773       instance_name = "icinga2"
774       instance_description = "icinga2 instance"
775
776       cleanup = {
777         downtimehistory_age = 48h
778         logentries_age = 31d
779       }
780
781       categories = DbCatConfig | DbCatState
782     }
783
784 Configuration Attributes:
785
786   Name            |Description
787   ----------------|----------------
788   host            |**Optional.** PostgreSQL database host address. Defaults to "localhost".
789   port            |**Optional.** PostgreSQL database port. Defaults to "5432".
790   user            |**Optional.** PostgreSQL database user with read/write permission to the icinga database. Defaults to "icinga".
791   password        |**Optional.** PostgreSQL database user's password. Defaults to "icinga".
792   database        |**Optional.** PostgreSQL database name. Defaults to "icinga".
793   table\_prefix   |**Optional.** PostgreSQL database table prefix. Defaults to "icinga\_".
794   instance\_name  |**Optional.** Unique identifier for the local Icinga 2 instance. Defaults to "default".
795   instance\_description|**Optional.** Description for the Icinga 2 instance.
796   enable_ha       |**Optional.** Enable the high availability functionality. Only valid in a [cluster setup](13-distributed-monitoring-ha.md#high-availability-db-ido). Defaults to "true".
797   failover_timeout | **Optional.** Set the failover timeout in a [HA cluster](13-distributed-monitoring-ha.md#high-availability-db-ido). Must not be lower than 60s. Defaults to "60s".
798   cleanup         |**Optional.** Dictionary with items for historical table cleanup.
799   categories      |**Optional.** The types of information that should be written to the database.
800
801 Cleanup Items:
802
803   Name            | Description
804   ----------------|----------------
805   acknowledgements_age |**Optional.** Max age for acknowledgements table rows (entry_time). Defaults to 0 (never).
806   commenthistory_age |**Optional.** Max age for commenthistory table rows (entry_time). Defaults to 0 (never).
807   contactnotifications_age |**Optional.** Max age for contactnotifications table rows (start_time). Defaults to 0 (never).
808   contactnotificationmethods_age |**Optional.** Max age for contactnotificationmethods table rows (start_time). Defaults to 0 (never).
809   downtimehistory_age |**Optional.** Max age for downtimehistory table rows (entry_time). Defaults to 0 (never).
810   eventhandlers_age |**Optional.** Max age for eventhandlers table rows (start_time). Defaults to 0 (never).
811   externalcommands_age |**Optional.** Max age for externalcommands table rows (entry_time). Defaults to 0 (never).
812   flappinghistory_age |**Optional.** Max age for flappinghistory table rows (event_time). Defaults to 0 (never).
813   hostchecks_age |**Optional.** Max age for hostalives table rows (start_time). Defaults to 0 (never).
814   logentries_age |**Optional.** Max age for logentries table rows (logentry_time). Defaults to 0 (never).
815   notifications_age |**Optional.** Max age for notifications table rows (start_time). Defaults to 0 (never).
816   processevents_age |**Optional.** Max age for processevents table rows (event_time). Defaults to 0 (never).
817   statehistory_age |**Optional.** Max age for statehistory table rows (state_time). Defaults to 0 (never).
818   servicechecks_age |**Optional.** Max age for servicechecks table rows (start_time). Defaults to 0 (never).
819   systemcommands_age |**Optional.** Max age for systemcommands table rows (start_time). Defaults to 0 (never).
820
821 Data Categories:
822
823   Name                 | Description            | Required by
824   ---------------------|------------------------|--------------------
825   DbCatConfig          | Configuration data     | Icinga Web/Reporting
826   DbCatState           | Current state data     | Icinga Web/Reporting
827   DbCatAcknowledgement | Acknowledgements       | Icinga Web/Reporting
828   DbCatComment         | Comments               | Icinga Web/Reporting
829   DbCatDowntime        | Downtimes              | Icinga Web/Reporting
830   DbCatEventHandler    | Event handler data     | Icinga Web/Reporting
831   DbCatExternalCommand | External commands      | Icinga Web/Reporting
832   DbCatFlapping        | Flap detection data    | Icinga Web/Reporting
833   DbCatCheck           | Check results          | --
834   DbCatLog             | Log messages           | Icinga Web/Reporting
835   DbCatNotification    | Notifications          | Icinga Web/Reporting
836   DbCatProgramStatus   | Program status data    | Icinga Web/Reporting
837   DbCatRetention       | Retention data         | Icinga Web/Reporting
838   DbCatStateHistory    | Historical state data  | Icinga Web/Reporting
839
840 Multiple categories can be combined using the `|` operator. In addition to
841 the category flags listed above the `DbCatEverything` flag may be used as
842 a shortcut for listing all flags.
843
844 External interfaces like Icinga Web require everything except `DbCatCheck`
845 which is the default value if `categories` is not set.
846
847 ## <a id="objecttype-livestatuslistener"></a> LiveStatusListener
848
849 Livestatus API interface available as TCP or UNIX socket. Historical table queries
850 require the [CompatLogger](6-object-types.md#objecttype-compatlogger) feature enabled
851 pointing to the log files using the `compat_log_path` configuration attribute.
852
853 Example:
854
855     library "livestatus"
856
857     object LivestatusListener "livestatus-tcp" {
858       socket_type = "tcp"
859       bind_host = "127.0.0.1"
860       bind_port = "6558"
861     }
862
863     object LivestatusListener "livestatus-unix" {
864       socket_type = "unix"
865       socket_path = "/var/run/icinga2/cmd/livestatus"
866     }
867
868 Configuration Attributes:
869
870   Name            |Description
871   ----------------|----------------
872   socket\_type      |**Optional.** Specifies the socket type. Can be either "tcp" or "unix". Defaults to "unix".
873   bind\_host        |**Optional.** Only valid when socket\_type is "tcp". Host address to listen on for connections. Defaults to "127.0.0.1".
874   bind\_port        |**Optional.** Only valid when `socket_type` is "tcp". Port to listen on for connections. Defaults to 6558.
875   socket\_path      |**Optional.** Only valid when `socket_type` is "unix". Specifies the path to the UNIX socket file. Defaults to RunDir + "/icinga2/cmd/livestatus".
876   compat\_log\_path |**Optional.** Required for historical table queries. Requires `CompatLogger` feature enabled. Defaults to LocalStateDir + "/log/icinga2/compat"
877
878 > **Note**
879 >
880 > UNIX sockets are not supported on Windows.
881
882
883 ## <a id="objecttype-notification"></a> Notification
884
885 Notification objects are used to specify how users should be notified in case
886 of host and service state changes and other events.
887
888 > **Best Practice**
889 >
890 > Rather than creating a `Notification` object for a specific host or service it is
891 > usually easier to just create a `Notification` template and use the `apply` keyword
892 > to assign the notification to a number of hosts or services. Use the `to` keyword
893 > to set the specific target type for `Host` or `Service`.
894 > Check the [notifications](3-monitoring-basics.md#notifications) chapter for detailed examples.
895
896 Example:
897
898     object Notification "localhost-ping-notification" {
899       host_name = "localhost"
900       service_name = "ping4"
901
902       command = "mail-notification"
903
904       users = [ "user1", "user2" ]
905
906       types = [ Problem, Recovery ]
907     }
908
909 Configuration Attributes:
910
911   Name                      | Description
912   --------------------------|----------------
913   host_name                 | **Required.** The name of the host this notification belongs to.
914   service_name              | **Optional.** The short name of the service this notification belongs to. If omitted this notification object is treated as host notification.
915   vars                      | **Optional.** A dictionary containing custom attributes that are specific to this notification object.
916   users                     | **Optional.** A list of user names who should be notified.
917   user_groups               | **Optional.** A list of user group names who should be notified.
918   times                     | **Optional.** A dictionary containing `begin` and `end` attributes for the notification.
919   command                   | **Required.** The name of the notification command which should be executed when the notification is triggered.
920   interval                  | **Optional.** The notification interval (in seconds). This interval is used for active notifications. Defaults to 30 minutes. If set to 0, [re-notifications](3-monitoring-basics.md#disable-renotification) are disabled.
921   period                    | **Optional.** The name of a time period which determines when this notification should be triggered. Not set by default.
922   zone                      |**Optional.** The zone this object is a member of.
923   types                     | **Optional.** A list of type filters when this notification should be triggered. By default everything is matched.
924   states                    | **Optional.** A list of state filters when this notification should be triggered. By default everything is matched.
925
926 Available notification state filters for Service:
927
928     OK
929     Warning
930     Critical
931     Unknown
932
933 Available notification state filters for Host:
934
935     Up
936     Down
937
938 Available notification type filters:
939
940     DowntimeStart
941     DowntimeEnd
942     DowntimeRemoved
943     Custom
944     Acknowledgement
945     Problem
946     Recovery
947     FlappingStart
948     FlappingEnd
949
950 Runtime Attributes:
951
952   Name                      | Type          | Description
953   --------------------------|---------------|-----------------
954   last\_notification        | Number        | When the last notification was sent for this Notification object (as a UNIX timestamp).
955   next\_notifcation         | Number        | When the next notification is going to be sent for this assuming the associated host/service is still in a non-OK state (as a UNIX timestamp).
956   notification\_number      | Number        | The notification number
957   last\_problem\_notification | Number      | When the last notification was sent for a problem (as a UNIX timestamp).
958
959
960 ## <a id="objecttype-notificationcommand"></a> NotificationCommand
961
962 A notification command definition.
963
964 Example:
965
966     object NotificationCommand "mail-service-notification" {
967       import "plugin-notification-command"
968
969       command = [
970         SysconfDir + "/icinga2/scripts/mail-notification.sh"
971       ]
972
973       env = {
974         NOTIFICATIONTYPE = "$notification.type$"
975         SERVICEDESC = "$service.name$"
976         HOSTALIAS = "$host.display_name$"
977         HOSTADDRESS = "$address$"
978         SERVICESTATE = "$service.state$"
979         LONGDATETIME = "$icinga.long_date_time$"
980         SERVICEOUTPUT = "$service.output$"
981         NOTIFICATIONAUTHORNAME = "$notification.author$"
982         NOTIFICATIONCOMMENT = "$notification.comment$"
983         HOSTDISPLAYNAME = "$host.display_name$"
984         SERVICEDISPLAYNAME = "$service.display_name$"
985         USEREMAIL = "$user.email$"
986       }
987     }
988
989 Configuration Attributes:
990
991   Name            |Description
992   ----------------|----------------
993   execute         |**Required.** The "execute" script method takes care of executing the notification. In virtually all cases you should import the "plugin-notification-command" template to take care of this setting.
994   command         |**Required.** The command. This can either be an array of individual command arguments. Alternatively a string can be specified in which case the shell interpreter (usually /bin/sh) takes care of parsing the command.
995   env             |**Optional.** A dictionary of macros which should be exported as environment variables prior to executing the command.
996   vars            |**Optional.** A dictionary containing custom attributes that are specific to this command.
997   timeout         |**Optional.** The command timeout in seconds. Defaults to 60 seconds.
998   arguments       |**Optional.** A dictionary of command arguments.
999
1000 Command arguments can be used the same way as for [CheckCommand objects](6-object-types.md#objecttype-checkcommand-arguments).
1001
1002
1003 ## <a id="objecttype-notificationcomponent"></a> NotificationComponent
1004
1005 The notification component is responsible for sending notifications. There are no configurable options.
1006
1007 Example:
1008
1009     library "notification"
1010
1011     object NotificationComponent "notification" { }
1012
1013 Configuration Attributes:
1014
1015   Name            |Description
1016   ----------------|----------------
1017   enable\_ha      |**Optional.** Enable the high availability functionality. Only valid in a [cluster setup](13-distributed-monitoring-ha.md#high-availability-notifications). Defaults to "true".
1018
1019 ## <a id="objecttype-opentsdbwriter"></a> OpenTsdbWriter
1020
1021 Writes check result metrics and performance data to [OpenTSDB](http://opentsdb.net).
1022
1023 Example:
1024
1025     library "perfdata"
1026
1027     object OpenTsdbWriter "opentsdb" {
1028       host = "127.0.0.1"
1029       port = 4242
1030     }
1031
1032 Configuration Attributes:
1033
1034   Name                  |Description
1035   ----------------------|----------------------
1036   host                  |**Optional.** OpenTSDB host address. Defaults to '127.0.0.1'.
1037   port                  |**Optional.** OpenTSDB port. Defaults to 4242.
1038
1039
1040 ## <a id="objecttype-perfdatawriter"></a> PerfdataWriter
1041
1042 Writes check result performance data to a defined path using macro
1043 pattern consisting of custom attributes and runtime macros.
1044
1045 Example:
1046
1047     library "perfdata"
1048
1049     object PerfdataWriter "pnp" {
1050       host_perfdata_path = "/var/spool/icinga2/perfdata/host-perfdata"
1051
1052       service_perfdata_path = "/var/spool/icinga2/perfdata/service-perfdata"
1053
1054       host_format_template = "DATATYPE::HOSTPERFDATA\tTIMET::$icinga.timet$\tHOSTNAME::$host.name$\tHOSTPERFDATA::$host.perfdata$\tHOSTCHECKCOMMAND::$host.check_command$\tHOSTSTATE::$host.state$\tHOSTSTATETYPE::$host.state_type$"
1055       service_format_template = "DATATYPE::SERVICEPERFDATA\tTIMET::$icinga.timet$\tHOSTNAME::$host.name$\tSERVICEDESC::$service.name$\tSERVICEPERFDATA::$service.perfdata$\tSERVICECHECKCOMMAND::$service.check_command$\tHOSTSTATE::$host.state$\tHOSTSTATETYPE::$host.state_type$\tSERVICESTATE::$service.state$\tSERVICESTATETYPE::$service.state_type$"
1056
1057       rotation_interval = 15s
1058     }
1059
1060 Configuration Attributes:
1061
1062   Name                    |Description
1063   ------------------------|----------------
1064   host_perfdata\_path     |**Optional.** Path to the host performance data file. Defaults to LocalStateDir + "/spool/icinga2/perfdata/host-perfdata".
1065   service_perfdata\_path  |**Optional.** Path to the service performance data file. Defaults to LocalStateDir + "/spool/icinga2/perfdata/service-perfdata".
1066   host_temp\_path         |**Optional.** Path to the temporary host file. Defaults to LocalStateDir + "/spool/icinga2/tmp/host-perfdata".
1067   service_temp\_path      |**Optional.** Path to the temporary service file. Defaults to LocalStateDir + "/spool/icinga2/tmp/service-perfdata".
1068   host_format\_template   |**Optional.** Host Format template for the performance data file. Defaults to a template that's suitable for use with PNP4Nagios.
1069   service_format\_template|**Optional.** Service Format template for the performance data file. Defaults to a template that's suitable for use with PNP4Nagios.
1070   rotation\_interval      |**Optional.** Rotation interval for the files specified in `{host,service}_perfdata_path`. Defaults to 30 seconds.
1071
1072 When rotating the performance data file the current UNIX timestamp is appended to the path specified
1073 in `host_perfdata_path` and `service_perfdata_path` to generate a unique filename.
1074
1075
1076 ## <a id="objecttype-scheduleddowntime"></a> ScheduledDowntime
1077
1078 ScheduledDowntime objects can be used to set up recurring downtimes for hosts/services.
1079
1080 > **Best Practice**
1081 >
1082 > Rather than creating a `ScheduledDowntime` object for a specific host or service it is usually easier
1083 > to just create a `ScheduledDowntime` template and use the `apply` keyword to assign the
1084 > scheduled downtime to a number of hosts or services. Use the `to` keyword to set the specific target
1085 > type for `Host` or `Service`.
1086 > Check the [recurring downtimes](5-advanced-topics.md#recurring-downtimes) example for details.
1087
1088 Example:
1089
1090     object ScheduledDowntime "some-downtime" {
1091       host_name = "localhost"
1092       service_name = "ping4"
1093
1094       author = "icingaadmin"
1095       comment = "Some comment"
1096
1097       fixed = false
1098       duration = 30m
1099
1100       ranges = {
1101         "sunday" = "02:00-03:00"
1102       }
1103     }
1104
1105 Configuration Attributes:
1106
1107   Name            |Description
1108   ----------------|----------------
1109   host_name       |**Required.** The name of the host this scheduled downtime belongs to.
1110   service_name    |**Optional.** The short name of the service this scheduled downtime belongs to. If omitted this downtime object is treated as host downtime.
1111   author          |**Required.** The author of the downtime.
1112   comment         |**Required.** A comment for the downtime.
1113   fixed           |**Optional.** Whether this is a fixed downtime. Defaults to true.
1114   duration        |**Optional.** How long the downtime lasts. Only has an effect for flexible (non-fixed) downtimes.
1115   ranges          |**Required.** A dictionary containing information which days and durations apply to this timeperiod.
1116
1117 ScheduledDowntime objects have composite names, i.e. their names are based
1118 on the `host_name` and `service_name` attributes and the
1119 name you specified. This means you can define more than one object
1120 with the same (short) name as long as one of the `host_name` and
1121 `service_name` attributes has a different value.
1122
1123
1124 ## <a id="objecttype-service"></a> Service
1125
1126 Service objects describe network services and how they should be checked
1127 by Icinga 2.
1128
1129 > **Best Practice**
1130 >
1131 > Rather than creating a `Service` object for a specific host it is usually easier
1132 > to just create a `Service` template and use the `apply` keyword to assign the
1133 > service to a number of hosts.
1134 > Check the [apply](3-monitoring-basics.md#using-apply) chapter for details.
1135
1136 Example:
1137
1138     object Service "uptime" {
1139       host_name = "localhost"
1140
1141       display_name = "localhost Uptime"
1142
1143       check_command = "check_snmp"
1144
1145       vars.community = "public"
1146       vars.oid = "DISMAN-EVENT-MIB::sysUpTimeInstance"
1147
1148       check_interval = 60s
1149       retry_interval = 15s
1150
1151       groups = [ "all-services", "snmp" ]
1152     }
1153
1154 Configuration Attributes:
1155
1156   Name            |Description
1157   ----------------|----------------
1158   display_name    |**Optional.** A short description of the service.
1159   host_name       |**Required.** The host this service belongs to. There must be a `Host` object with that name.
1160   name            |**Required.** The service name. Must be unique on a per-host basis (Similar to the service_description attribute in Icinga 1.x).
1161   groups          |**Optional.** The service groups this service belongs to.
1162   vars            |**Optional.** A dictionary containing custom attributes that are specific to this service.
1163   check\_command  |**Required.** The name of the check command.
1164   max\_check\_attempts|**Optional.** The number of times a service is re-checked before changing into a hard state. Defaults to 3.
1165   check\_period   |**Optional.** The name of a time period which determines when this service should be checked. Not set by default.
1166   check\_interval |**Optional.** The check interval (in seconds). This interval is used for checks when the service is in a `HARD` state. Defaults to 5 minutes.
1167   retry\_interval |**Optional.** The retry interval (in seconds). This interval is used for checks when the service is in a `SOFT` state. Defaults to 1 minute.
1168   enable\_notifications|**Optional.** Whether notifications are enabled. Defaults to true.
1169   enable\_active\_checks|**Optional.** Whether active checks are enabled. Defaults to true.
1170   enable\_passive\_checks|**Optional.** Whether passive checks are enabled. Defaults to true.
1171   enable\_event\_handler|**Optional.** Enables event handlers for this host. Defaults to true.
1172   enable\_flapping|**Optional.** Whether flap detection is enabled. Defaults to false.
1173   enable\_perfdata|**Optional.** Whether performance data processing is enabled. Defaults to true.
1174   event\_command  |**Optional.** The name of an event command that should be executed every time the service's state changes or the service is in a `SOFT` state.
1175   flapping\_threshold|**Optional.** The flapping threshold in percent when a service is considered to be flapping.
1176   volatile        |**Optional.** The volatile setting enables always `HARD` state types if `NOT-OK` state changes occur.
1177   zone            |**Optional.** The zone this object is a member of.
1178   command\_endpoint|**Optional.** The endpoint where commands are executed on.
1179   notes           |**Optional.** Notes for the service.
1180   notes\_url      |**Optional.** Url for notes for the service (for example, in notification commands).
1181   action_url      |**Optional.** Url for actions for the service (for example, an external graphing tool).
1182   icon\_image     |**Optional.** Icon image for the service. Used by external interfaces only.
1183   icon\_image\_alt|**Optional.** Icon image description for the service. Used by external interface only.
1184
1185 Service objects have composite names, i.e. their names are based on the host_name attribute and the name you specified. This means
1186 you can define more than one object with the same (short) name as long as the `host_name` attribute has a different value.
1187
1188 Runtime Attributes:
1189
1190   Name                      | Type          | Description
1191   --------------------------|---------------|-----------------
1192   next\_check               | Number        | When the next check occurs (as a UNIX timestamp).
1193   check\_attempt            | Number        | The current check attempt number.
1194   state\_type               | Number        | The current state type (0 = SOFT, 1 = HARD).
1195   last\_state\_type         | Number        | The previous state type (0 = SOFT, 1 = HARD).
1196   last\_reachable           | Boolean       | Whether the service was reachable when the last check occurred.
1197   last\_check\_result       | CheckResult   | The current check result.
1198   last\_state\_change       | Number        | When the last state change occurred (as a UNIX timestamp).
1199   last\_hard\_state\_change | Number        | When the last hard state change occurred (as a UNIX timestamp).
1200   last\_in\_downtime        | Boolean       | Whether the service was in a downtime when the last check occurred.
1201   acknowledgement           | Number        | The acknowledgement type (0 = NONE, 1 = NORMAL, 2 = STICKY).
1202   acknowledgement_expiry    | Number        | When the acknowledgement expires (as a UNIX timestamp; 0 = no expiry).
1203   comments                  | Dictionary    | The comments for this service.
1204   downtimes                 | Dictionary    | The downtimes for this service.
1205   state                     | Number        | The current state (0 = OK, 1 = WARNING, 2 = CRITICAL, 3 = UNKNOWN).
1206   last\_state               | Number        | The previous state (0 = OK, 1 = WARNING, 2 = CRITICAL, 3 = UNKNOWN).
1207   last\_hard\_state         | Number        | The last hard state (0 = OK, 1 = WARNING, 2 = CRITICAL, 3 = UNKNOWN).
1208
1209
1210 ## <a id="objecttype-servicegroup"></a> ServiceGroup
1211
1212 A group of services.
1213
1214 > **Best Practice**
1215 >
1216 > Assign service group members using the [group assign](18-language-reference.md#group-assign) rules.
1217
1218 Example:
1219
1220     object ServiceGroup "snmp" {
1221       display_name = "SNMP services"
1222     }
1223
1224 Configuration Attributes:
1225
1226   Name            |Description
1227   ----------------|----------------
1228   display_name    |**Optional.** A short description of the service group.
1229   groups          |**Optional.** An array of nested group names.
1230
1231
1232 ## <a id="objecttype-statusdatawriter"></a> StatusDataWriter
1233
1234 Periodically writes status data files which are used by the Classic UI and other third-party tools.
1235
1236 Example:
1237
1238     library "compat"
1239
1240     object StatusDataWriter "status" {
1241         status_path = "/var/cache/icinga2/status.dat"
1242         objects_path = "/var/cache/icinga2/objects.cache"
1243         update_interval = 30s
1244     }
1245
1246 Configuration Attributes:
1247
1248   Name            |Description
1249   ----------------|----------------
1250   status\_path    |**Optional.** Path to the status.dat file. Defaults to LocalStateDir + "/cache/icinga2/status.dat".
1251   objects\_path   |**Optional.** Path to the objects.cache file. Defaults to LocalStateDir + "/cache/icinga2/objects.cache".
1252   update\_interval|**Optional.** The interval in which the status files are updated. Defaults to 15 seconds.
1253
1254
1255 ## <a id="objecttype-sysloglogger"></a> SyslogLogger
1256
1257 Specifies Icinga 2 logging to syslog.
1258
1259 Example:
1260
1261     object SyslogLogger "crit-syslog" {
1262       severity = "critical"
1263     }
1264
1265 Configuration Attributes:
1266
1267   Name            |Description
1268   ----------------|----------------
1269   severity        |**Optional.** The minimum severity for this log. Can be "debug", "notice", "information", "warning" or "critical". Defaults to "warning".
1270
1271
1272 ## <a id="objecttype-timeperiod"></a> TimePeriod
1273
1274 Time periods can be used to specify when hosts/services should be checked or to limit
1275 when notifications should be sent out.
1276
1277 Examples:
1278
1279     object TimePeriod "nonworkhours" {
1280       import "legacy-timeperiod"
1281
1282       display_name = "Icinga 2 TimePeriod for non working hours"
1283
1284       ranges = {
1285         monday = "00:00-8:00,17:00-24:00"
1286         tuesday = "00:00-8:00,17:00-24:00"
1287         wednesday = "00:00-8:00,17:00-24:00"
1288         thursday = "00:00-8:00,17:00-24:00"
1289         friday = "00:00-8:00,16:00-24:00"
1290         saturday = "00:00-24:00"
1291         sunday = "00:00-24:00"
1292       }
1293     }
1294
1295     object TimePeriod "exampledays" {
1296         import "legacy-timeperiod"
1297
1298         display_name = "Icinga 2 TimePeriod for random example days"
1299
1300         ranges = {
1301             //We still believe in Santa, no peeking!
1302             //Applies every 25th of December every year
1303             "december 25" = "00:00-24:00"
1304
1305             //Any point in time can be specified,
1306             //but you still have to use a range
1307             "2038-01-19" = "03:13-03:15"
1308
1309             //Evey 3rd day from the second monday of February
1310             //to 8th of November
1311             "monday 2 february - november 8 / 3" = "00:00-24:00"
1312         }
1313     }
1314
1315
1316 Additional examples can be found [within the icinga documentation](http://docs.icinga.org/latest/en/objectdefinitions.html#objectdefinitions-timeperiod).
1317
1318 Configuration Attributes:
1319
1320   Name            |Description
1321   ----------------|----------------
1322   display_name    |**Optional.** A short description of the time period.
1323   update          |**Required.** The "update" script method takes care of updating the internal representation of the time period. In virtually all cases you should import the "legacy-timeperiod" template to take care of this setting.
1324   ranges          |**Required.** A dictionary containing information which days and durations apply to this timeperiod.
1325
1326 The `/etc/icinga2/conf.d/timeperiods.conf` file is usually used to define
1327 timeperiods including this one.
1328
1329 Runtime Attributes:
1330
1331   Name                      | Type          | Description
1332   --------------------------|---------------|-----------------
1333   is\_inside                | Boolean       | Whether we're currently inside this timeperiod.
1334
1335
1336 ## <a id="objecttype-user"></a> User
1337
1338 A user.
1339
1340 Example:
1341
1342     object User "icingaadmin" {
1343       display_name = "Icinga 2 Admin"
1344       groups = [ "icingaadmins" ]
1345       email = "icinga@localhost"
1346       pager = "icingaadmin@localhost.localdomain"
1347
1348       period = "24x7"
1349
1350       states = [ OK, Warning, Critical, Unknown ]
1351       types = [ Problem, Recovery ]
1352
1353       vars.additional_notes = "This is the Icinga 2 Admin account."
1354     }
1355
1356 Available notification state filters:
1357
1358     OK
1359     Warning
1360     Critical
1361     Unknown
1362     Up
1363     Down
1364
1365 Available notification type filters:
1366
1367     DowntimeStart
1368     DowntimeEnd
1369     DowntimeRemoved
1370     Custom
1371     Acknowledgement
1372     Problem
1373     Recovery
1374     FlappingStart
1375     FlappingEnd
1376
1377 Configuration Attributes:
1378
1379   Name            |Description
1380   ----------------|----------------
1381   display_name    |**Optional.** A short description of the user.
1382   email           |**Optional.** An email string for this user. Useful for notification commands.
1383   pager           |**Optional.** A pager string for this user. Useful for notification commands.
1384   vars            |**Optional.** A dictionary containing custom attributes that are specific to this user.
1385   groups          |**Optional.** An array of group names.
1386   enable_notifications|**Optional.** Whether notifications are enabled for this user.
1387   period          |**Optional.** The name of a time period which determines when a notification for this user should be triggered. Not set by default.
1388   types           |**Optional.** A set of type filters when this notification should be triggered. By default everything is matched.
1389   states          |**Optional.** A set of state filters when this notification should be triggered. By default everything is matched.
1390
1391 Runtime Attributes:
1392
1393   Name                      | Type          | Description
1394   --------------------------|---------------|-----------------
1395   last\_notification        | Number        | When the last notification was sent for this user (as a UNIX timestamp).
1396
1397 ## <a id="objecttype-usergroup"></a> UserGroup
1398
1399 A user group.
1400
1401 > **Best Practice**
1402 >
1403 > Assign user group members using the [group assign](18-language-reference.md#group-assign) rules.
1404
1405 Example:
1406
1407     object UserGroup "icingaadmins" {
1408         display_name = "Icinga 2 Admin Group"
1409     }
1410
1411 Configuration Attributes:
1412
1413   Name            |Description
1414   ----------------|----------------
1415   display_name    |**Optional.** A short description of the user group.
1416   groups          |**Optional.** An array of nested group names.
1417
1418
1419 ## <a id="objecttype-zone"></a> Zone
1420
1421 Zone objects are used to specify which Icinga 2 instances are located in a zone.
1422
1423 Example:
1424
1425     object Zone "config-ha-master" {
1426       endpoints = [ "icinga2a", "icinga2b" ]
1427
1428     }
1429
1430     object Zone "check-satellite" {
1431       endpoints = [ "icinga2c" ]
1432       parent = "config-ha-master"
1433     }
1434
1435 Configuration Attributes:
1436
1437   Name            |Description
1438   ----------------|----------------
1439   endpoints       |**Optional.** Dictionary with endpoints located in this zone.
1440   parent          |**Optional.** The name of the parent zone.
1441   global          |**Optional.** Whether configuration files for this zone should be synced to all endpoints. Defaults to false.