]> granicus.if.org Git - icinga2/blob - doc/8-migration.md
DB IDO: Add documentation for HA functionality
[icinga2] / doc / 8-migration.md
1 # <a id="migration"></a> Migration from Icinga 1.x
2
3 ## <a id="configuration-migration"></a> Configuration Migration
4
5 The Icinga 2 configuration format introduces plenty of behavioural changes. In
6 order to ease migration from Icinga 1.x, Icinga 2 ships its own config migration
7 script.
8
9 ### <a id="configuration-migration-script"></a> Configuration Migration Script
10
11 A standalone configuration migration script is available at
12 https://github.com/Icinga/icinga2-migration. All further
13 details on the command line parameters are documented there too.
14
15 This script will be merged back upstream into the Icinga Web 2 CLI once there
16 is a final stable release.
17
18 Please note that not each configuration detail, trick or attribute will work.
19 Some specific migration steps will be still required to be done manually,
20 especially if you want to preserve your existing file layout, or any other
21 object specific policies.
22
23 If you encounter a bug, please open an issue at https://dev.icinga.org
24
25 ### <a id="manual-config-migration"></a> Manual Config Migration
26
27 For a long-term migration of your configuration you should consider re-creating
28 your configuration based on the proposed Icinga 2 configuration paradigm.
29
30 Please read the [next chapter](#differences-1x-2) to find out more about the differences
31 between 1.x and 2.
32
33 ### <a id="manual-config-migration-hints"></a> Manual Config Migration Hints
34
35 These hints should provide you with enough details for manually migrating your configuration,
36 or to adapt your configuration export tool to dump Icinga 2 configuration instead of
37 Icinga 1.x configuration.
38
39 The examples are taken from Icinga 1.x test and production environments and converted
40 straight into a possible Icinga 2 format. If you found a different strategy, send a patch!
41
42 If you require in-depth explanations, please check the [next chapter](#differences-1x-2).
43
44 #### <a id="manual-config-migration-hints-Intervals"></a> Manual Config Migration Hints for Intervals
45
46 By default all intervals without any duration literal are interpreted as seconds. Therefore
47 all existing Icinga 1.x `*_interval` attributes require an additional `m` duration literal.
48
49 Icinga 1.x:
50
51     define service {
52       service_description             service1
53       host_name                       localhost1
54       check_command                   test_customvar
55       use                             generic-service
56       check_interval                  5
57       retry_interval                  1
58     }
59
60 Icinga 2:
61
62     object Service "service1" {
63       import "generic-service"
64       host_name = "localhost1"
65       check_command = "test_customvar"
66       check_interval = 5m
67       retry_interval = 1m
68     }
69
70 #### <a id="manual-config-migration-hints-services"></a> Manual Config Migration Hints for Services
71
72 If you have used the `host_name` attribute in Icinga 1.x with one or more host names this service
73 belongs to, you can migrate this to the [apply rules](#using-apply) syntax.
74
75 Icinga 1.x:
76
77     define service {
78       service_description             service1
79       host_name                       localhost1,localhost2
80       check_command                   test_check
81       use                             generic-service
82     }
83
84 Icinga 2:
85
86     apply Service "service1" {
87       import "generic-service"
88       check_command = "test_check"
89
90       assign where host.name in [ "localhost1", "localhost2" ]
91     }
92
93 In Icinga 1.x you would have organized your services with hostgroups using the `hostgroup_name` attribute
94 like the following example:
95
96     define service {
97       service_description             servicewithhostgroups
98       hostgroup_name                  hostgroup1,hostgroup3
99       check_command                   test_check
100       use                             generic-service
101     }
102
103 Using Icinga 2 you can migrate this to the [apply rules](#using-apply) syntax:
104
105     apply Service "servicewithhostgroups" {
106       import "generic-service"
107       check_command = "test_check"
108
109       assign where "hostgroup1" in host.groups
110       assign where "hostgroup3" in host.groups
111     }
112
113
114 #### <a id="manual-config-migration-hints-group-members"></a> Manual Config Migration Hints for Group Members
115
116 The Icinga 1.x hostgroup `hg1` has two members `host1` and `host2`. The hostgroup `hg2` has `host3` as
117 a member and includes all members of the `hg1` hostgroup.
118
119     define hostgroup {
120       hostgroup_name                  hg1
121       members                         host1,host2
122     }
123
124     define hostgroup {
125       hostgroup_name                  hg2
126       members                         host3
127       hostgroup_members               hg1
128     }
129
130 This can be migrated to Icinga 2 and [using group assign](#group-assign). The additional nested hostgroup
131 `hg1` is included into `hg2` with the `groups` attribute.
132
133
134     object HostGroup "hg1" {
135       assign where host.name in [ "host1", "host2" ]
136     }
137
138     object HostGroup "hg2" {
139       groups = [ "hg1" ]
140       assign where host.name == "host3"
141     }
142
143 These assign rules can be applied for all groups: `HostGroup`, `ServiceGroup` and `UserGroup`
144 (requires renaming from `contactgroup`).
145
146 > **Tip**
147 >
148 > Define custom attributes and assign/ignore members based on these attribute pattern matches.
149
150
151
152 #### <a id="manual-config-migration-hints-check-command-arguments"></a> Manual Config Migration Hints for Check Command Arguments
153
154 Host and service check command arguments are separated by a `!` in Icinga 1.x. Their order is important and they
155 are referenced as `$ARGn$` where `n` is the argument counter.
156
157     define command {
158       command_name                      my-ping
159       command_line                      $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
160     }
161
162     define service {
163       use                               generic-service
164       host_name                         my-server
165       service_description               my-ping
166       check_command                     my-ping-check!100.0,20%!500.0,60%
167     }
168
169 While you could manually migrate this like (please note the new generic command arguments and default argument values!):
170
171     object CheckCommand "my-ping-check" {
172       import "plugin-check-command"
173
174       command = [
175         PluginDir + "/check_ping", "-4"
176       ]
177
178       arguments = {
179         "-H" = "$ping_address$"
180         "-w" = "$ping_wrta$,$ping_wpl$%"
181         "-c" = "$ping_crta$,$ping_cpl$%"
182         "-p" = "$ping_packets$"
183         "-t" = "$ping_timeout$"
184       }
185
186       vars.ping_address = "$address$"
187       vars.ping_wrta = 100
188       vars.ping_wpl = 5
189       vars.ping_crta = 200
190       vars.ping_cpl = 15
191     }
192
193     object Service "my-ping" {
194       import "generic-service"
195       host_name = "my-server"
196       check_command = "my-ping-check"
197
198       vars.ping_wrta = 100
199       vars.ping_wpl = 20
200       vars.ping_crta = 500
201       vars.ping_cpl = 60
202     }
203
204 There also is a quick programmatical workaround for this (example exported from LConf). Define a generic
205 check command importing the basic template, and also setting the `$USER1$` macro. Assign it to the global
206 `PluginDir` constant.
207
208     template CheckCommand "generic-check-command" {
209       import "plugin-check-command"
210
211       vars.USER1 = PluginDir
212     }
213
214 Every check command importing the `generic-check-command` template will now automatically set the new plugin
215 directory - one major problem solved.
216
217 For the check command it is required to
218
219 * Escape all double quotes with an additional `\`.
220 * Replace all [runtime macros](#manual-config-migration-hints-runtime-macros), e.g. `$HOSTADDRESS$` with `$address$`.
221 * Replace [custom variable macros](#manual-config-migration-hints-runtime-custom-attributes) if any.
222 * Keep `$ARGn$` macros.
223
224 The final check command looks like this in Icinga2:
225
226     object CheckCommand "ping4" {
227       import "generic-check-command"
228
229       command = "$USER1$/check_ping -H $address$ -w $ARG1$ -c $ARG2$ -p 5"
230     }
231
232 The service object will now set the command arguments as `ARGn` custom attributes.
233
234     check_command                     ping4!100.0,20%!500.0,60%
235
236 This command line can be split by the `!` separator into
237
238 * `ping4` (command name, keep it for Icinga 2)
239 * `100.0,20%` as `vars.ARG1`
240 * `500.0,60%` as `vars.ARG2`
241
242 The final service could look like:
243
244     apply Service "ping4" {
245       import "generic-service"
246
247       check_command = "ping4"
248
249       vars.ARG1 = "100.0,20%"
250       vars.ARG2 = "500.0,60%"
251
252       assign where host.name == "my-server"
253     }
254
255 That way the old command arguments fashion can be applied for Icinga 2, although it's not recommended.
256
257
258 #### <a id="manual-config-migration-hints-runtime-macros"></a> Manual Config Migration Hints for Runtime Macros
259
260 Runtime macros have been renamed. A detailed comparison table can be found [here](#differences-1x-2-runtime-macros).
261
262 For example, accessing the service check output looks like the following in Icinga 1.x:
263
264     $SERVICEOUTPUT$
265
266 In Icinga 2 you will need to write:
267
268     $service.output$
269
270
271 #### <a id="manual-config-migration-hints-runtime-custom-attributes"></a> Manual Config Migration Hints for Runtime Custom Attributes
272
273 Custom variables from Icinga 1.x are available as Icinga 2 custom attributes.
274
275     define command {
276       command_name                    test_customvar
277       command_line                    echo "Host CV: $_HOSTCVTEST$ Service CV: $_SERVICECVTEST$\n"
278     }
279
280     define host {
281       host_name                       localhost1
282       check_command                   test_customvar
283       use                             generic-host
284       _CVTEST                         host cv value
285     }
286
287     define service {
288       service_description             service1
289       host_name                       localhost1
290       check_command                   test_customvar
291       use                             generic-service
292       _CVTEST                         service cv value
293     }
294
295 Can be written as the following in Icinga 2:
296
297     object CheckCommand "test_customvar" {
298       import "plugin-check-command"
299       command = "echo "Host CV: $host.vars.CVTEST$ Service CV: $service.vars.CVTEST$\n""
300     }
301
302     object Host "localhost1" {
303       import "generic-host"
304       check_command = "test_customvar"
305       vars.CVTEST = "host cv value"
306     }
307
308     object Service "service1" {
309       host_name = "localhost1"
310       check_command = "test_customvar"
311       vars.CVTEST = "service cv value"
312     }
313
314 If you are just defining `$CVTEST$` in your command definition its value depends on the
315 execution scope - the host check command will fetch the host attribute value of `vars.CVTEST`
316 while the service check command resolves its value to the service attribute attribute `vars.CVTEST`.
317
318 #### <a id="manual-config-migration-hints-contacts-users"></a> Manual Config Migration Hints for Contacts (Users)
319
320 Contacts in Icinga 1.x act as users in Icinga 2, but do not have any notification commands specified.
321 This migration part is explained in the [next chapter](#manual-config-migration-hints-notifications).
322
323     define contact{
324       contact_name                    testconfig-user
325       use                             generic-user
326       alias                           Icinga Test User
327       service_notification_options    c,f,s,u
328       email                           icinga@localhost
329     }
330
331 The `service_notification_options` can be [mapped](#manual-config-migration-hints-notification-filters)
332 into generic `state` and `type` filters, if additional notification filtering is required. `alias` gets
333 renamed to `display_name`.
334
335     object User "testconfig-user" {
336       import "generic-user"
337       display_name = "Icinga Test User"
338       email = "icinga@localhost"
339     }
340
341 This user can be put into usergroups (former contactgroups) or referenced in newly migration notification
342 objects.
343
344 #### <a id="manual-config-migration-hints-notifications"></a> Manual Config Migration Hints for Notifications
345
346 If you are migrating a host or service notification, you'll need to extract the following information from
347 your existing Icinga 1.x configuration objects
348
349 * host/service attribute `contacts` and `contact_groups`
350 * host/service attribute `notification_options`
351 * host/service attribute `notification_period`
352 * host/service attribute `notification_interval`
353
354 The clean approach is to refactor your current contacts and their notification command methods into a
355 generic strategy
356
357 * host or service has a notification type (for example mail)
358 * which contacts (users) are notified by mail?
359 * do the notification filters, periods, intervals still apply for them? (do a cleanup during migration)
360 * assign users and groups to these notifications
361 * Redesign the notifications into generic [apply rules](#using-apply-notifications)
362
363
364 The ugly workaround solution could look like this:
365
366 Extract all contacts from the remaining groups, and create a unique list. This is required for determining
367 the host and service notification commands involved.
368
369 * contact attributes `host_notification_commands` and `service_notification_commands` (can be a comma separated list)
370 * get the command line for each notification command and store them for later
371 * create a new notification name and command name
372
373 Generate a new notification object based on these values. Import the generic template based on the type (`host` or `service`).
374 Assign it to the host or service and set the newly generated notification command name as `command` attribute.
375
376     object Notification "<notificationname>" {
377       import "mail-host-notification"
378       host_name = "<thishostname>"
379       command = "<notificationcommandname>"
380
381
382 Convert the `notification_options` attribute from Icinga 1.x to Icinga 2 `states` and `types`. Details
383 [here](#manual-config-migration-hints-notification-filters). Add the notification period.
384
385       states = [ OK, Warning, Critical ]
386       types = [ Recovery, Problem, Custom ]
387       period = "24x7"
388
389 The current contact acts as `users` attribute.
390
391       users = [ "<contactwithnotificationcommand>" ]
392     }
393
394 Do this in a loop for all notification commands (depending if host or service contact). Once done, dump the
395 collected notification commands.
396
397 The result of this migration are lots of unnecessary notification objects and commands but it will unroll
398 the Icinga 1.x logic into the revamped Icinga 2 notification object schema. If you are looking for code
399 examples, try [LConf](https://www.netways.org).
400
401
402
403 #### <a id="manual-config-migration-hints-notification-filters"></a> Manual Config Migration Hints for Notification Filters
404
405 Icinga 1.x defines all notification filters in an attribute called `notification_options`. Using Icinga 2 you will
406 have to split these values into the `states` and `types` attributes.
407
408 > **Note**
409 >
410 > `Recovery` type requires the `Ok` state.
411 > `Custom` and `Problem` should always be set as `type` filter.
412
413   Icinga 1.x option     | Icinga 2 state        | Icinga 2 type
414   ----------------------|-----------------------|-------------------
415   o                     | OK (Up for hosts)     |
416   w                     | Warning               | Problem
417   c                     | Critical              | Problem
418   u                     | Unknown               | Problem
419   d                     | Down                  | Problem
420   s                     | .                     | DowntimeStart / DowntimeEnd / DowntimeRemoved
421   r                     | Ok                    | Recovery
422   f                     | .                     | FlappingStart / FlappingEnd
423   n                     | 0  (none)             | 0 (none)
424   .                     | .                     | Custom
425
426
427
428 #### <a id="manual-config-migration-hints-escalations"></a> Manual Config Migration Hints for Escalations
429
430 Escalations in Icinga 1.x are a bit tricky. By default service escalations can be applied to hosts and
431 hostgroups and require a defined service object.
432
433 The following example applies a service escalation to the service `dep_svc01` and all hosts in the `hg_svcdep2`
434 hostgroup. The default `notification_interval` is set to `10` minutes notifying the `cg_admin` contact.
435 After 20 minutes (`10*2`, notification_interval * first_notification) the notification is escalated to the
436 `cg_ops` contactgroup until 60 minutes (`10*6`) have passed.
437
438     define service {
439       service_description             dep_svc01
440       host_name                       dep_hostsvc01,dep_hostsvc03
441       check_command                   test2
442       use                             generic-service
443       notification_interval           10
444       contact_groups                  cg_admin
445     }
446
447     define hostgroup {
448       hostgroup_name                  hg_svcdep2
449       members                         dep_hostsvc03
450     }
451
452     # with hostgroup_name and service_description
453     define serviceescalation {
454       hostgroup_name                  hg_svcdep2
455       service_description             dep_svc01
456       first_notification              2
457       last_notification               6
458       contact_groups                  cg_ops
459     }
460
461 In Icinga 2 the service and hostgroup definition will look quite the same. Save the `notification_interval`
462 and `contact_groups` attribute for an additional notification.
463
464     apply Service "dep_svc01" {
465       import "generic-service"
466
467       check_command = "test2"
468
469       assign where host.name == "dep_hostsvc01"
470       assign where host.name == "dep_hostsvc03"
471     }
472
473     object HostGroup "hg_svcdep2" {
474       assign where host.name == "dep_hostsvc03"
475     }
476
477     apply Notification "email" to Service {
478       import "service-mail-notification"
479
480       interval = 10m
481       user_groups = [ "cg_admin" ]
482
483       assign where service.name == "dep_svc01" && (host.name == "dep_hostsvc01" || host.name == "dep_hostsvc03")
484     }
485
486 Calculate the begin and end time for the newly created escalation notification:
487
488 * begin = first_notification * notification_interval = 2 * 10m = 20m
489 * end = last_notification * notification_interval = 6 * 10m = 60m = 1h
490
491 Assign the notification escalation to the service `dep_svc01` on all hosts in the hostgroup `hg_svcdep2`.
492
493     apply Notification "email-escalation" to Service {
494       import "service-mail-notification"
495
496       interval = 10m
497       user_groups = [ "cg_ops" ]
498
499       times = {
500         begin = 20m
501         end = 1h
502       }
503
504       assign where service.name == "dep_svc01" && "hg_svcdep2" in host.groups
505     }
506
507 The assign rule could be made more generic and the notification be applied to more than
508 just this service belonging to hosts in the matched hostgroup.
509
510
511 > **Note**
512 >
513 > When the notification is escalated, Icinga 1.x suppresses notifications to the default contacts.
514 > In Icinga 2 an escalation is an additional notification with a defined begin and end time. The
515 > `email` notification will continue as normal.
516
517
518
519 #### <a id="manual-config-migration-hints-dependencies"></a> Manual Config Migration Hints for Dependencies
520
521 There are some dependency examples already in the [basics chapter](#dependencies). Dependencies in
522 Icinga 1.x can be confusing in terms of which host/service is the parent and which host/service acts
523 as the child.
524
525 While Icinga 1.x defines `notification_failure_criteria` and `execution_failure_criteria` as dependency
526 filters, this behaviour has changed in Icinga 2. There is no 1:1 migration but generally speaking
527 the state filter defined in the `execution_failure_criteria` defines the Icinga 2 `state` attribute.
528 If the state filter matches, you can define whether to disable checks and notifications or not.
529
530 The following example describes service dependencies. If you migrate from Icinga 1.x you will only
531 want to use the classic `Host-to-Host` and `Service-to-Service` dependency relationships.
532
533     define service {
534       service_description             dep_svc01
535       hostgroup_name                  hg_svcdep1
536       check_command                   test2
537       use                             generic-service
538     }
539
540     define service {
541       service_description             dep_svc02
542       hostgroup_name                  hg_svcdep2
543       check_command                   test2
544       use                             generic-service
545     }
546
547     define hostgroup {
548       hostgroup_name                  hg_svcdep2
549       members                         host2
550     }
551
552     define host{
553       use                             linux-server-template
554       host_name                       host1
555       address                         192.168.1.10
556     }
557
558     # with hostgroup_name and service_description
559     define servicedependency {
560       host_name                       host1
561       dependent_hostgroup_name        hg_svcdep2
562       service_description             dep_svc01
563       dependent_service_description   *
564       execution_failure_criteria      u,c
565       notification_failure_criteria   w,u,c
566       inherits_parent                 1
567     }
568
569 Map the dependency attributes accordingly.
570
571   Icinga 1.x            | Icinga 2
572   ----------------------|---------------------
573   host_name             | parent_host_name
574   dependent_host_name   | child_host_name (used in assign/ignore)
575   dependent_hostgroup_name | all child hosts in group (used in assign/ignore)
576   service_description   | parent_service_name
577   dependent_service_description | child_service_name (used in assign/ignore)
578
579 And migrate the host and services.
580
581     object Host "host1" {
582       import "linux-server-template"
583       address = "192.168.1.10"
584     }
585
586     object HostGroup "hg_svcdep2" {
587       assign where host.name == "host2"
588     }
589
590     apply Service "dep_svc01" {
591       import "generic-service"
592       check_command = "test2"
593
594       assign where "hp_svcdep1" in host.groups
595     }
596
597     apply Service "dep_svc02" {
598       import "generic-service"
599       check_command = "test2"
600
601       assign where "hp_svcdep2" in host.groups
602     }
603
604 When it comes to the `execution_failure_criteria` and `notification_failure_criteria` attribute migration,
605 you will need to map the most common values, in this example `u,c` (`Unknown` and `Critical` will cause the
606 dependency to fail). Therefore the `Dependency` should be ok on Ok and Warning. `inherits_parents` is always
607 enabled.
608
609     apply Dependency "all-svc-for-hg-hg_svcdep2-on-host1-dep_svc01" to Service {
610       parent_host_name = "host1"
611       parent_service_name = "dep_svc01"
612
613       states = [ Ok, Warning ]
614       disable_checks = true
615       disable_notifications = true
616
617       assign where "hg_svcdep2" in host.groups
618     }
619
620 Host dependencies are explained in the [next chapter](#manual-config-migration-hints-host-parents).
621
622
623
624 #### <a id="manual-config-migration-hints-host-parents"></a> Manual Config Migration Hints for Host Parents
625
626 Host parents from Icinga 1.x are migrated into `Host-to-Host` dependencies in Icinga 2.
627
628 The following example defines the `vmware-master` host as parent host for the guest
629 virtual machines `vmware-vm1` and `vmware-vm2`.
630
631 By default all hosts in the hostgroup `vmware` should get the parent assigned. This isn't really
632 solvable with Icinga 1.x parents, but only with host dependencies.
633
634     define host{
635       use                             linux-server-template
636       host_name                       vmware-master
637       hostgroups                      vmware
638       address                         192.168.1.10
639     }
640
641     define host{
642       use                             linux-server-template
643       host_name                       vmware-vm1
644       hostgroups                      vmware
645       address                         192.168.27.1
646       parents                         vmware-master
647     }
648
649     define host{
650       use                             linux-server-template
651       host_name                       vmware-vm2
652       hostgroups                      vmware
653       address                         192.168.28.1
654       parents                         vmware-master
655     }
656
657 By default all hosts in the hostgroup `vmware` should get the parent assigned (but not the `vmware-master`
658 host itself). This isn't really solvable with Icinga 1.x parents, but only with host dependencies as shown
659 below:
660
661     define hostdependency {
662       dependent_hostgroup_name        vmware
663       dependent_host_name             !vmware-master
664       host_name                       vmware-master
665       inherits_parent                 1
666       notification_failure_criteria   d,u
667       execution_failure_criteria      d,u
668       dependency_period               testconfig-24x7
669     }
670
671 When migrating to Icinga 2, the parents must be changed to a newly created host dependency.
672
673
674 Map the following attributes
675
676   Icinga 1.x            | Icinga 2
677   ----------------------|---------------------
678   host_name             | parent_host_name
679   dependent_host_name   | child_host_name (used in assign/ignore)
680   dependent_hostgroup_name | all child hosts in group (used in assign/ignore)
681
682 The Icinga 2 configuration looks like this:
683
684
685     object Host "vmware-master" {
686       import "linux-server-template"
687       groups += [ "vmware" ]
688       address = "192.168.1.10"
689       vars.is_vmware_master = true
690     }
691
692     object Host "vmware-vm1" {
693       import "linux-server-template"
694       groups += [ "vmware" ]
695       address = "192.168.27.1"
696     }
697
698     object Host "vmware-vm2" {
699       import "linux-server-template"
700       groups += [ "vmware" ]
701       address = "192.168.28.1"
702     }
703
704     apply Dependency "vmware-master" to Host {
705       parent_host_name = "vmware-master"
706
707       assign where "vmware" in host.groups
708       ignore where host.vars.is_vmware_master
709       ignore where host.name == "vmware-master"
710     }
711
712 For easier identification you could add the `vars.is_vmware_master` attribute to the `vmware-master`
713 host and let the dependency ignore that instead of the hardcoded host name. That's different
714 to the Icinga 1.x example and a best practice hint only.
715
716
717 #### <a id="manual-config-migration-hints-distributed-setup"></a> Manual Config Migration Hints for Distributed Setups
718
719 * Icinga 2 does not use active/passive instances calling OSCP commands and requiring the NSCA
720 daemon for passing check results between instances.
721 * Icinga 2 does not support any 1.x NEB addons for check load distribution
722
723 * If your current setup consists of instances distributing the check load, you should consider
724 building a [load distribution](#cluster-scenarios-load-distribution) setup with Icinga 2.
725 * If your current setup includes active/passive clustering with external tools like Pacemaker/DRBD
726 consider the [High Availability](#cluster-scenarios-high-availability) setup.
727 * If you have build your own custom configuration deployment and check result collecting mechanism
728 you should re-design your setup and re-evaluate your requirements, and how they may be fulfilled
729 using the Icinga 2 cluster capabilities.
730
731
732 ## <a id="differences-1x-2"></a> Differences between Icinga 1.x and 2
733
734 ### <a id="differences-1x-2-configuration-format"></a> Configuration Format
735
736 Icinga 1.x supports two configuration formats: key-value-based settings in the
737 `icinga.cfg` configuration file and object-based in included files (`cfg_dir`,
738 `cfg_file`). The path to the `icinga.cfg` configuration file must be passed to
739 the Icinga daemon at startup.
740
741     enable_notifications=1
742
743     define service {
744        notifications_enabled    0
745     }
746
747 Icinga 2 supports objects and (global) variables, but does not make a difference
748 if it's the main configuration file, or any included file.
749
750     const EnableNotifications = true
751
752     object Service "test" {
753         enable_notifications = 0
754     }
755
756 #### <a id="differences-1x-2-sample-configuration-itl"></a> Sample Configuration and ITL
757
758 While Icinga 1.x ships sample configuration and templates spread in various
759 object files, Icinga 2 moves all templates into the Icinga Template Library (ITL)
760 and includes them in the sample configuration.
761
762 Additional plugin check commands are shipped with Icinga 2 as well.
763
764 The ITL will be updated on every release and should not be edited by the user.
765
766 There are still generic templates available for your convenience which may or may
767 not be re-used in your configuration. For instance, `generic-service` includes
768 all required attributes except `check_command` for a service.
769
770 Sample configuration files are located in the `conf.d/` directory which is
771 included in `icinga2.conf` by default.
772
773 ### <a id="differences-1x-2-main-config"></a> Main Config File
774
775 In Icinga 1.x there are many global configuration settings available in `icinga.cfg`.
776 Icinga 2 only uses a small set of [global constants](#global-constants) allowing
777 you to specify certain different setting such as the `NodeName` in a cluster scenario.
778
779 Aside from that, the [icinga2.conf](#icinga2-conf) should take care of including
780 global constants, enabled [features](#features) and the object configuration.
781
782 ### <a id="differences-1x-2-include-files-dirs"></a> Include Files and Directories
783
784 In Icinga 1.x the `icinga.cfg` file contains `cfg_file` and `cfg_dir`
785 directives. The `cfg_dir` directive recursively includes all files with a `.cfg`
786 suffix in the given directory. Only absolute paths may be used. The `cfg_file`
787 and `cfg_dir` directives can include the same file twice which leads to
788 configuration errors in Icinga 1.x.
789
790     cfg_file=/etc/icinga/objects/commands.cfg
791     cfg_dir=/etc/icinga/objects
792
793 Icinga 2 supports wildcard includes and relative paths, e.g. for including
794 `conf.d/*.conf` in the same directory.
795
796     include "conf.d/*.conf"
797
798 If you want to include files and directories recursively, you need to define
799 a separate option and add the directory and an optional pattern.
800
801     include_recursive "conf.d"
802
803 A global search path for includes is available for advanced features like
804 the Icinga Template Library (ITL) or additional monitoring plugins check
805 command configuration.
806
807     include <itl>
808     include <plugins>
809
810 By convention the `.conf` suffix is used for Icinga 2 configuration files.
811
812 ### <a id="differences-1x-2-resource-file-global-macros"></a> Resource File and Global Macros
813
814 Global macros such as for the plugin directory, usernames and passwords can be
815 set in the `resource.cfg` configuration file in Icinga 1.x. By convention the
816 `USER1` macro is used to define the directory for the plugins.
817
818 Icinga 2 uses global constants instead. In the default config these are
819 set in the `constants.conf` configuration file:
820
821     /**
822      * This file defines global constants which can be used in
823      * the other configuration files. At a minimum the
824      * PluginDir constant should be defined.
825      */
826
827     const PluginDir = "/usr/lib/nagios/plugins"
828
829 [Global macros](#global-constants) can only be defined once. Trying to modify a
830 global constant will result in an error.
831
832 ### <a id="differences-1x-2-configuration-comments"></a> Configuration Comments
833
834 In Icinga 1.x comments are made using a leading hash (`#`) or a semi-colon (`;`)
835 for inline comments.
836
837 In Icinga 2 comments can either be encapsulated by `/*` and `*/` (allowing for
838 multi-line comments) or starting with two slashes (`//`). A leading hash (`#`)
839 could also be used.
840
841 ### <a id="differences-1x-2-object-names"></a> Object names
842
843 Object names must not contain an exclamation mark (`!`). Use the `display_name` attribute
844 to specify user-friendly names which should be shown in UIs (supported by
845 Icinga 1.x Classic UI and Web).
846
847 Object names are not specified using attributes (e.g. `service_description` for
848 services) like in Icinga 1.x but directly after their type definition.
849
850     define service {
851         host_name  localhost
852         service_description  ping4
853     }
854
855     object Service "ping4" {
856       host_name = "localhost"
857     }
858
859 ### <a id="differences-1x-2-templates"></a> Templates
860
861 In Icinga 1.x templates are identified using the `register 0` setting. Icinga 2
862 uses the `template` identifier:
863
864     template Service "ping4-template" { }
865
866 Icinga 1.x objects inherit from templates using the `use` attribute.
867 Icinga 2 uses the keyword `import` with template names in double quotes.
868
869     define service {
870         service_description testservice
871         use                 tmpl1,tmpl2,tmpl3
872     }
873
874     object Service "testservice" {
875       import "tmpl1"
876       import "tmpl2"
877       import "tmpl3"
878     }
879
880 The last template overrides previously set values.
881
882 ### <a id="differences-1x-2-object-attributes"></a> Object attributes
883
884 Icinga 1.x separates attribute and value pairs with whitespaces/tabs. Icinga 2
885 requires an equal sign (=) between them.
886
887     define service {
888         check_interval  5
889     }
890
891     object Service "test" {
892         check_interval = 5m
893     }
894
895 Please note that the default time value is seconds, if no duration literal
896 is given. `check_interval = 5` behaves the same as `check_interval = 5s`.
897
898 All strings require double quotes in Icinga 2. Therefore a double quote
899 must be escaped by a backslash (e.g. in command line).
900 If an attribute identifier starts with a number, it must be enclosed
901 in double quotes as well.
902
903 #### <a id="differences-1x-2-alias-display-name"></a> Alias vs. Display Name
904
905 In Icinga 1.x a host can have an `alias` and a `display_name` attribute used
906 for a more descriptive name. A service only can have a `display_name` attribute.
907 The `alias` is used for group, timeperiod, etc. objects too.
908 Icinga 2 only supports the `display_name` attribute which is also taken into
909 account by Icinga web interfaces.
910
911 ### <a id="differences-1x-2-custom-attributes"></a> Custom Attributes
912
913 Icinga 2 allows you to define custom attributes in the `vars` dictionary.
914 The `notes`, `notes_url`, `action_url`, `icon_image`, `icon_image_alt`
915 attributes for host and service objects are still available in Icinga 2.
916
917 `2d_coords` and `statusmap_image` are not supported in Icinga 2.
918
919 #### <a id="differences-1x-2-custom-variables"></a> Custom Variables
920
921 Icinga 1.x custom variable attributes must be prefixed using an underscore (`_`).
922 In Icinga 2 these attributes must be added to the `vars` dictionary as custom attributes.
923
924     vars.dn = "cn=icinga2-dev-host,ou=icinga,ou=main,ou=IcingaConfig,ou=LConf,dc=icinga,dc=org"
925     vars.cv = "my custom cmdb description"
926
927 These custom attributes are also used as [command parameters](#command-passing-parameters).
928
929 ### <a id="differences-1x-2-host-service-relation"></a> Host Service Relation
930
931 In Icinga 1.x a service object is associated with a host by defining the
932 `host_name` attribute in the service definition. Alternate methods refer
933 to `hostgroup_name` or behaviour changing regular expression.
934
935 The preferred way of associating hosts with services in Icinga 2 is by
936 using the [apply](#using-apply) keyword.
937
938 ### <a id="differences-1x-2-users"></a> Users
939
940 Contacts have been renamed to users (same for groups). A user does not
941 only provide attributes and custom attributes used for notifications, but is also
942 used for authorization checks.
943
944 In Icinga 2 notification commands are not directly associated with users.
945 Instead the notification command is specified using `Notification` objects.
946
947 The `StatusDataWriter`, `IdoMySqlConnection` and `LivestatusListener` types will
948 provide the contact and contactgroups attributes for services for compatibility
949 reasons. These values are calculated from all services, their notifications,
950 and their users.
951
952 ### <a id="differences-1x-2-macros"></a> Macros
953
954 Various object attributes and runtime variables can be accessed as macros in
955 commands in Icinga 1.x - Icinga 2 supports all required [custom attributes](#custom-attributes).
956
957 #### <a id="differences-1x-2-command-arguments"></a> Command Arguments
958
959 If you have previously used Icinga 1.x you may already be familiar with
960 user and argument definitions (e.g., `USER1` or `ARG1`). Unlike in Icinga 1.x
961 the Icinga 2 custom attributes may have arbitrary names and arguments are no
962 longer specified in the `check_command` setting.
963
964 In Icinga 1.x arguments are specified in the `check_command` attribute and
965 are separated from the command name using an exclamation mark (`!`).
966
967     define command {
968         command_name  ping4
969         command_line  $USER1$/check_ping -H $address$ -w $ARG1$ -c $ARG2$ -p 5
970     }
971
972     define service {
973         use                     local-service
974         host_name               localhost
975         service_description     PING
976         check_command           ping4!100.0,20%!500.0,60%
977     }
978
979 With the freely definable custom attributes in Icinga 2 it looks like this:
980
981     object CheckCommand "ping4" {
982         command = PluginDir + "/check_ping -H $address$ -w $wrta$,$wpl%$ -c $crta$,$cpl%$"
983     }
984
985     object Service "PING" {
986         check_command = "ping4"
987         vars.wrta = 100
988         vars.wpl = 20
989         vars.crta = 500
990         vars.cpl = 60
991     }
992
993 > **Note**
994 >
995 > For better maintainability you should consider using [command arguments](#command-arguments)
996 > for your check commands.
997
998 > **Note**
999 >
1000 > The Classic UI feature named `Command Expander` does not work with Icinga 2.
1001
1002 #### <a id="differences-1x-2-environment-macros"></a> Environment Macros
1003
1004 The global configuration setting `enable_environment_macros` does not exist in
1005 Icinga 2.
1006
1007 Macros exported into the [environment](#runtime-custom-attribute-env-vars)
1008 must be set using the `env` attribute in command objects.
1009
1010 #### <a id="differences-1x-2-runtime-macros"></a> Runtime Macros
1011
1012 Icinga 2 requires an object specific namespace when accessing configuration
1013 and stateful runtime macros. Custom attributes can be accessed directly.
1014
1015 Changes to user (contact) runtime macros
1016
1017   Icinga 1.x             | Icinga 2
1018   -----------------------|----------------------
1019   CONTACTNAME            | user.name
1020   CONTACTALIAS           | user.display_name
1021   CONTACTEMAIL           | user.email
1022   CONTACTPAGER           | user.pager
1023
1024 `CONTACTADDRESS*` is not supported but can be accessed as `$user.vars.address1$`
1025 if set.
1026
1027 Changes to service runtime macros
1028
1029   Icinga 1.x             | Icinga 2
1030   -----------------------|----------------------
1031   SERVICEDESC            | service.name
1032   SERVICEDISPLAYNAME     | service.display_name
1033   SERVICECHECKCOMMAND    | service.check_command
1034   SERVICESTATE           | service.state
1035   SERVICESTATEID         | service.state_id
1036   SERVICESTATETYPE       | service.state_type
1037   SERVICEATTEMPT         | service.check_attempt
1038   MAXSERVICEATTEMPT      | service.max_check_attempts
1039   LASTSERVICESTATE       | service.last_state
1040   LASTSERVICESTATEID     | service.last_state_id
1041   LASTSERVICESTATETYPE   | service.last_state_type
1042   LASTSERVICESTATECHANGE | service.last_state_change
1043   SERVICEDURATIONSEC     | service.duration_sec
1044   SERVICELATENCY         | service.latency
1045   SERVICEEXECUTIONTIME   | service.execution_time
1046   SERVICEOUTPUT          | service.output
1047   SERVICEPERFDATA        | service.perfdata
1048   LASTSERVICECHECK       | service.last_check
1049   SERVICENOTES           | service.notes
1050   SERVICENOTESURL        | service.notes_url
1051   SERVICEACTIONURL       | service.action_url
1052
1053
1054 Changes to host runtime macros
1055
1056   Icinga 1.x             | Icinga 2
1057   -----------------------|----------------------
1058   HOSTNAME               | host.name
1059   HOSTADDRESS            | host.address
1060   HOSTADDRESS6           | host.address6
1061   HOSTDISPLAYNAME        | host.display_name
1062   HOSTALIAS              | (use `host.display_name` instead)
1063   HOSTCHECKCOMMAND       | host.check_command
1064   HOSTSTATE              | host.state
1065   HOSTSTATEID            | host.state_id
1066   HOSTSTATETYPE          | host.state_type
1067   HOSTATTEMPT            | host.check_attempt
1068   MAXHOSTATTEMPT         | host.max_check_attempts
1069   LASTHOSTSTATE          | host.last_state
1070   LASTHOSTSTATEID        | host.last_state_id
1071   LASTHOSTSTATETYPE      | host.last_state_type
1072   LASTHOSTSTATECHANGE    | host.last_state_change
1073   HOSTDURATIONSEC        | host.duration_sec
1074   HOSTLATENCY            | host.latency
1075   HOSTEXECUTIONTIME      | host.execution_time
1076   HOSTOUTPUT             | host.output
1077   HOSTPERFDATA           | host.perfdata
1078   LASTHOSTCHECK          | host.last_check
1079   HOSTNOTES              | host.notes
1080   HOSTNOTESURL           | host.notes_url
1081   HOSTACTIONURL          | host.action_url
1082   TOTALSERVICES          | host.num_services
1083   TOTALSERVICESOK        | host.num_services_ok
1084   TOTALSERVICESWARNING   | host.num_services_warning
1085   TOTALSERVICESUNKNOWN   | host.num_services_unknown
1086   TOTALSERVICESCRITICAL  | host.num_services_critical
1087
1088 Changes to command runtime macros
1089
1090   Icinga 1.x             | Icinga 2
1091   -----------------------|----------------------
1092   COMMANDNAME            | command.name
1093
1094 Changes to notification runtime macros
1095
1096   Icinga 1.x             | Icinga 2
1097   -----------------------|----------------------
1098   NOTIFICATIONTYPE       | notification.type
1099   NOTIFICATIONAUTHOR     | notification.author
1100   NOTIFICATIONCOMMENT    | notification.comment
1101   NOTIFICATIONAUTHORNAME | (use `notification.author`)
1102   NOTIFICATIONAUTHORALIAS   | (use `notification.author`)
1103
1104
1105 Changes to global runtime macros:
1106
1107   Icinga 1.x             | Icinga 2
1108   -----------------------|----------------------
1109   TIMET                  | icinga.timet
1110   LONGDATETIME           | icinga.long_date_time
1111   SHORTDATETIME          | icinga.short_date_time
1112   DATE                   | icinga.date
1113   TIME                   | icinga.time
1114   PROCESSSTARTTIME       | icinga.uptime
1115
1116 Changes to global statistic macros:
1117
1118   Icinga 1.x                        | Icinga 2
1119   ----------------------------------|----------------------
1120   TOTALHOSTSUP                      | icinga.num_hosts_up
1121   TOTALHOSTSDOWN                    | icinga.num_hosts_down
1122   TOTALHOSTSUNREACHABLE             | icinga.num_hosts_unreachable
1123   TOTALHOSTSDOWNUNHANDLED           | --
1124   TOTALHOSTSUNREACHABLEUNHANDLED    | --
1125   TOTALHOSTPROBLEMS                 | down
1126   TOTALHOSTPROBLEMSUNHANDLED        | down-(downtime+acknowledged)
1127   TOTALSERVICESOK                   | icinga.num_services_ok
1128   TOTALSERVICESWARNING              | icinga.num_services_warning
1129   TOTALSERVICESCRITICAL             | icinga.num_services_critical
1130   TOTALSERVICESUNKNOWN              | icinga.num_services_unknown
1131   TOTALSERVICESWARNINGUNHANDLED     | --
1132   TOTALSERVICESCRITICALUNHANDLED    | --
1133   TOTALSERVICESUNKNOWNUNHANDLED     | --
1134   TOTALSERVICEPROBLEMS              | ok+warning+critical+unknown
1135   TOTALSERVICEPROBLEMSUNHANDLED     | warning+critical+unknown-(downtime+acknowledged)
1136
1137
1138
1139
1140 ### <a id="differences-1x-2-external-commands"></a> External Commands
1141
1142 `CHANGE_CUSTOM_CONTACT_VAR` was renamed to `CHANGE_CUSTOM_USER_VAR`.
1143 `CHANGE_CONTACT_MODATTR` was renamed to `CHANGE_USER_MODATTR`.
1144
1145 The following external commands are not supported:
1146
1147     CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD
1148     CHANGE_HOST_NOTIFICATION_TIMEPERIOD
1149     CHANGE_SVC_NOTIFICATION_TIMEPERIOD
1150     DEL_DOWNTIME_BY_HOSTGROUP_NAME
1151     DEL_DOWNTIME_BY_START_TIME_COMMENT
1152     DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST
1153     DISABLE_CONTACT_HOST_NOTIFICATIONS
1154     DISABLE_CONTACT_SVC_NOTIFICATIONS
1155     DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS
1156     DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS
1157     DISABLE_FAILURE_PREDICTION
1158     DISABLE_HOST_AND_CHILD_NOTIFICATIONS
1159     DISABLE_HOST_FRESHNESS_CHECKS
1160     DISABLE_HOST_SVC_NOTIFICATIONS
1161     DISABLE_NOTIFICATIONS_EXPIRE_TIME
1162     DISABLE_SERVICE_FRESHNESS_CHECKS
1163     ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST
1164     ENABLE_CONTACT_HOST_NOTIFICATIONS
1165     ENABLE_CONTACT_SVC_NOTIFICATIONS
1166     ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS
1167     ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS
1168     ENABLE_FAILURE_PREDICTION
1169     ENABLE_HOST_AND_CHILD_NOTIFICATIONS
1170     ENABLE_HOST_FRESHNESS_CHECKS
1171     ENABLE_HOST_SVC_NOTIFICATIONS
1172     ENABLE_SERVICE_FRESHNESS_CHECKS
1173     READ_STATE_INFORMATION
1174     SAVE_STATE_INFORMATION
1175     SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME
1176     SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME
1177     SET_HOST_NOTIFICATION_NUMBER
1178     SET_SVC_NOTIFICATION_NUMBER
1179     START_ACCEPTING_PASSIVE_HOST_CHECKS
1180     START_ACCEPTING_PASSIVE_SVC_CHECKS
1181     START_OBSESSING_OVER_HOST
1182     START_OBSESSING_OVER_HOST_CHECKS
1183     START_OBSESSING_OVER_SVC
1184     START_OBSESSING_OVER_SVC_CHECKS
1185     STOP_ACCEPTING_PASSIVE_HOST_CHECKS
1186     STOP_ACCEPTING_PASSIVE_SVC_CHECKS
1187     STOP_OBSESSING_OVER_HOST
1188     STOP_OBSESSING_OVER_HOST_CHECKS
1189     STOP_OBSESSING_OVER_SVC
1190     STOP_OBSESSING_OVER_SVC_CHECKS
1191
1192 ### <a id="differences-1x-2-async-event-execution"></a> Asynchronous Event Execution
1193
1194 Unlike Icinga 1.x, Icinga 2 does not block when it waits for a check command
1195 being executed. Similar when a notification or event handler is triggered - they
1196 run asynchronously in their own thread.
1197
1198 Writing performance data files or status data and log files doesn't block either.
1199 Last but not least the external command pipe runs asynchronously and accepts
1200 multiple connections at once.
1201
1202 ### <a id="differences-1x-2-checks"></a> Checks
1203
1204 #### <a id="differences-1x-2-check-output"></a> Check Output
1205
1206 Icinga 2 does not make a difference between `output` (first line) and
1207 `long_output` (remaining lines) like in Icinga 1.x. Performance Data is
1208 provided separately.
1209
1210 There is no output length restriction as known from Icinga 1.x using an
1211 [8KB static buffer](http://docs.icinga.org/latest/en/pluginapi.html#outputlengthrestrictions).
1212
1213 The `StatusDataWriter`, `IdoMysqlConnection` and `LivestatusListener` types
1214 split the raw output into `output` (first line) and `long_output` (remaining
1215 lines) for compatibility reasons.
1216
1217 #### <a id="differences-1x-2-initial-state"></a> Initial State
1218
1219 Icinga 1.x uses the `max_service_check_spread` setting to specify a timerange
1220 where the initial state checks must have happened. Icinga 2 will use the
1221 `retry_interval` setting instead and `check_interval` divided by 5 if
1222 `retry_interval` is not defined.
1223
1224 ### <a id="differences-1x-2-comments"></a> Comments
1225
1226 Icinga 2 doesn't support non-persistent comments.
1227
1228 ### <a id="differences-1x-2-commands"></a> Commands
1229
1230 Unlike in Icinga 1.x there are three different command types in Icinga 2:
1231 `CheckCommand`, `NotificationCommand`, and `EventCommand`.
1232
1233 For example in Icinga 1.x it is possible to accidently use a notification
1234 command as an event handler which might cause problems depending on which
1235 runtime macros are used in the notification command.
1236
1237 In Icinga 2 these command types are separated and will generate an error on
1238 configuration validation if used in the wrong context.
1239
1240 While Icinga 2 still supports the complete command line in command objects, it's
1241 also possible to encapsulate all arguments into double quotes and passing them
1242 as array to the `command_line` attribute i.e. for better readability.
1243
1244 It's also possible to define default custom attributes for the command itself which can be
1245 overridden by a service macro.
1246
1247 ### <a id="differences-1x-2-groups"></a> Groups
1248
1249 In Icinga 2 hosts, services and users are added to groups using the `groups`
1250 attribute in the object. The old way of listing all group members in the group's
1251 `members` attribute is available through `assign where` and `ignore where`
1252 conditions.
1253
1254     object Host "web-dev" {
1255       import "generic-host"
1256     }
1257
1258     object HostGroup "dev-hosts" {
1259       display_name = "Dev Hosts"
1260       assign where match("*-dev", host.name)
1261     }
1262
1263 #### <a id="differences-1x-2-service-hostgroup-host"></a> Add Service to Hostgroup where Host is Member
1264
1265 In order to associate a service with all hosts in a host group the `apply`
1266 keyword can be used:
1267
1268     apply Service "ping4" {
1269       import "generic-service"
1270
1271       check_command = "ping4"
1272
1273       assign where "dev-hosts" in host.groups
1274     }
1275
1276 ### <a id="differences-1x-2-notifications"></a> Notifications
1277
1278 Notifications are a new object type in Icinga 2. Imagine the following
1279 notification configuration problem in Icinga 1.x:
1280
1281 * Service A should notify contact X via SMS
1282 * Service B should notify contact X via Mail
1283 * Service C should notify contact Y via Mail and SMS
1284 * Contact X and Y should also be used for authorization (e.g. in Classic UI)
1285
1286 The only way achieving a semi-clean solution is to
1287
1288 * Create contact X-sms, set service_notification_command for sms, assign contact
1289   to service A
1290 * Create contact X-mail, set service_notification_command for mail, assign
1291   contact to service B
1292 * Create contact Y, set service_notification_command for sms and mail, assign
1293   contact to service C
1294 * Create contact X without notification commands, assign to service A and B
1295
1296 Basically you are required to create duplicated contacts for either each
1297 notification method or used for authorization only.
1298
1299 Icinga 2 attempts to solve that problem in this way
1300
1301 * Create user X, set SMS and Mail attributes, used for authorization
1302 * Create user Y, set SMS and Mail attributes, used for authorization
1303 * Create notification A-SMS, set command for sms, add user X,
1304   assign notification A-SMS to service A
1305 * Create notification B-Mail, set command for mail, add user X,
1306   assign notification Mail to service B
1307 * Create notification C-SMS, set command for sms, add user Y,
1308   assign notification C-SMS to service C
1309 * Create notification C-Mail, set command for mail, add user Y,
1310   assign notification C-Mail to service C
1311
1312 Previously in Icinga 1.x it looked like this:
1313
1314     service -> (contact, contactgroup) -> notification command
1315
1316 In Icinga 2 it will look like this:
1317
1318     Service -> Notification -> NotificationCommand
1319                             -> User, UserGroup
1320
1321 #### <a id="differences-1x-2-escalations"></a> Escalations
1322
1323 Escalations in Icinga 1.x require a separated object matching on existing
1324 objects. Escalations happen between a defined start and end time which is
1325 calculated from the notification_interval:
1326
1327     start = notification start + (notification_interval * first_notification)
1328     end = notification start + (notification_interval * last_notification)
1329
1330 In theory first_notification and last_notification can be set to readable
1331 numbers. In practice users are manipulating those attributes in combination
1332 with notification_interval in order to get a start and end time.
1333
1334 In Icinga 2 the notification object can be used as notification escalation
1335 if the start and end times are defined within the 'times' attribute using
1336 duration literals (e.g. 30m).
1337
1338 The Icinga 2 escalation does not replace the current running notification.
1339 In Icinga 1.x it's required to copy the contacts from the service notification
1340 to the escalation to guarantee the normal notifications once an escalation
1341 happens.
1342 That's not necessary with Icinga 2 only requiring an additional notification
1343 object for the escalation itself.
1344
1345 #### <a id="differences-1x-2-notification-options"></a> Notification Options
1346
1347 Unlike Icinga 1.x with the 'notification_options' attribute with comma-separated
1348 state and type filters, Icinga 2 uses two configuration attributes for that.
1349 All state and type filter use long names OR'd with a pipe together
1350
1351     notification_options w,u,c,r,f,s
1352
1353     states = [ Warning, Unknown, Critical ]
1354     filters = [ Problem, Recovery, FlappingStart, FlappingEnd, DowntimeStart, DowntimeEnd, DowntimeRemoved ]
1355
1356 Icinga 2 adds more fine-grained type filters for acknowledgements, downtime
1357 and flapping type (start, end, ...).
1358
1359 ### <a id="differences-1x-2-dependencies-parents"></a> Dependencies and Parents
1360
1361 In Icinga 1.x it's possible to define host parents to determine network reachability
1362 and keep a host's state unreachable rather than down.
1363 Furthermore there are host and service dependencies preventing unnecessary checks and
1364 notifications. A host must not depend on a service, and vice versa. All dependencies
1365 are configured as separate objects and cannot be set directly on the host or service
1366 object.
1367
1368 A service can now depend on a host, and vice versa. A service has an implicit dependency
1369 (parent) to its host. A host to host dependency acts implicitly as host parent relation.
1370
1371 The former `host_name` and `dependent_host_name` have been renamed to `parent_host_name`
1372 and `child_host_name` (same for the service attribute). When using apply rules the
1373 child attributes may be omitted.
1374
1375 For detailed examples on how to use the dependencies please check the [dependencies](#dependencies)
1376 chapter.
1377
1378 Dependencies can be applied to hosts or services using the [apply rules](#apply).
1379
1380 The `StatusDataWriter`, `IdoMysqlConnection` and `LivestatusListener` types
1381 support the Icinga 1.x schema with dependencies and parent attributes for
1382 compatibility reasons.
1383
1384 ### <a id="differences-1x-2-flapping"></a> Flapping
1385
1386 The Icinga 1.x flapping detection uses the last 21 states of a service. This
1387 value is hardcoded and cannot be changed. The algorithm on determining a flapping state
1388 is as follows:
1389
1390     flapping value = (number of actual state changes / number of possible state changes)
1391
1392 The flapping value is then compared to the low and high flapping thresholds.
1393
1394 The algorithm used in Icinga 2 does not store the past states but calculcates the flapping
1395 threshold from a single value based on counters and half-life values. Icinga 2 compares
1396 the value with a single flapping threshold configuration attribute.
1397
1398 ### <a id="differences-1x-2-check-result-freshness"></a> Check Result Freshness
1399
1400 Freshness of check results must be enabled explicitly in Icinga 1.x. The attribute
1401 `freshness_threshold` defines the threshold in seconds. Once the threshold is triggered, an
1402 active freshness check is executed defined by the `check_command` attribute. Both check
1403 methods (active and passive) use the same freshness check method.
1404
1405 In Icinga 2 active check freshness is determined by the `check_interval` attribute and no
1406 incoming check results in that period of time (last check + check interval). Passive check
1407 freshness is calculated from the `check_interval` attribute if set. There is no extra
1408 `freshness_threshold` attribute in Icinga 2. If the freshness checks are invalid, a new
1409 service check is forced.
1410
1411 ### <a id="differences-1x-2-real-reload"></a> Real Reload
1412
1413 In Nagios / Icinga 1.x a daemon reload happens like this
1414
1415 * receive reload signal SIGHUP
1416 * stop all events (checks, notifications, etc)
1417 * read the configuration from disk and validate all config objects in a single threaded fashion
1418 * validation NOT ok: stop the daemon (cannot restore old config state)
1419 * validation ok: start with new objects, dump status.dat / ido
1420
1421 Unlike Icinga 1.x the Icinga 2 daemon reload happens asynchronously.
1422
1423 * receive reload signal SIGHUP
1424 * fork a child process, start configuration validation in parallel work queues
1425 * parent process continues with old configuration objects and the event scheduling
1426 (doing checks, replicating cluster events, triggering alert notifications, etc.)
1427 * validation NOT ok: child process terminates, parent process continues with old configuration state
1428 (this is ESSENTIAL for the [cluster config synchronisation](#cluster-zone-config-sync))
1429 * validation ok: child process signals parent process to terminate and save its current state
1430 (all events til now) into the icinga2 state file
1431 * parent process shuts down writing icinga2.state file
1432 * child process waits for parent process gone, reads the icinga2 state file and synchronizes all historical and status data
1433 * child becomes the new session leader
1434
1435 The DB IDO configuration dump and status/historical event updates also runs asynchronously in a queue not blocking the core anymore. Same goes for any other enabled feature running in its own thread.
1436 The configuration validation itself runs in parallel allowing fast verification checks.
1437
1438 That way you are not blind (anymore) during a configuration reload and benefit from a real scalable architecture.
1439
1440
1441 ### <a id="differences-1x-2-state-retention"></a> State Retention
1442
1443 Icinga 1.x uses the `retention.dat` file to save its state in order to be able
1444 to reload it after a restart. In Icinga 2 this file is called `icinga2.state`.
1445
1446 The format objects are stored in is not compatible with Icinga 1.x.
1447
1448 ### <a id="differences-1x-2-logging"></a> Logging
1449
1450 Icinga 1.x supports syslog facilities and writes its own `icinga.log` log file
1451 and archives. These logs are used in Icinga 1.x Classic UI to generate
1452 historical reports.
1453
1454 Icinga 2 compat library provides the CompatLogger object which writes the icinga.log and archive
1455 in Icinga 1.x format in order to stay compatible with Classic UI and other addons.
1456
1457 The native Icinga 2 logging facilities are split into three configuration objects: SyslogLogger,
1458 FileLogger, StreamLogger. Each of them has their own severity and target configuration.
1459
1460 The Icinga 2 daemon log does not log any alerts but is considered an application log only.
1461
1462 ### <a id="differences-1x-2-broker-modules-features"></a> Broker Modules and Features
1463
1464 Icinga 1.x broker modules are incompatible with Icinga 2.
1465
1466 In order to provide compatibility with Icinga 1.x the functionality of several
1467 popular broker modules was implemented for Icinga 2:
1468
1469 * IDOUtils
1470 * Livestatus
1471 * Cluster (allows for high availability and load balancing)
1472
1473
1474 ### <a id="differences-1x-2-distributed-monitoring"></a> Distributed Monitoring
1475
1476 Icinga 1.x uses the native "obsess over host/service" method which requires the NSCA addon
1477 passing the slave's check results passively onto the master's external command pipe.
1478 While this method may be used for check load distribution, it does not provide any configuration
1479 distribution out-of-the-box. Furthermore comments, downtimes and other stateful runtime data is
1480 not synced between the master and slave nodes. There are addons available solving the check
1481 and configuration distribution problems Icinga 1.x distributed monitoring currently suffers from.
1482
1483 Icinga 2 implements a new built-in [distributed monitoring architecture](#distributed-monitoring-high-availability),
1484 including config and check distribution, IPv4/IPv6 support, SSL certificates and zone support for DMZ.
1485 High Availability and load balancing are also part of the Icinga 2 Cluster setup.