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