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