]> granicus.if.org Git - icinga2/blob - doc/2-getting-started.md
Documentation: Clarify on DB IDO upgrades
[icinga2] / doc / 2-getting-started.md
1 # <a id="getting-started"></a> Getting Started
2
3 This tutorial is a step-by-step introduction to installing Icinga 2 and
4 available Icinga web interfaces. It assumes that you are familiar with
5 the system you're installing Icinga 2 on.
6
7 Details on troubleshooting problems can be found [here](#troubleshooting).
8
9 ## <a id="setting-up-icinga2"></a> Setting up Icinga 2
10
11 First off you will have to install Icinga 2. The preferred way of doing this
12 is to use the official package repositories depending on which operating system
13 and distribution you are running.
14
15   Distribution            | Repository
16   ------------------------|---------------------------
17   Debian                  | [Upstream](https://packages.debian.org/sid/icinga2), [DebMon](http://debmon.org/packages/debmon-wheezy/icinga2), [Icinga Repository](http://packages.icinga.org/debian/)
18   Ubuntu                  | [Upstream](https://launchpad.net/ubuntu/+source/icinga2), [Icinga PPA](https://launchpad.net/~formorer/+archive/ubuntu/icinga), [Icinga Repository](http://packages.icinga.org/ubuntu/)
19   RHEL/CentOS             | [Icinga Repository](http://packages.icinga.org/epel/)
20   OpenSUSE                | [Icinga Repository](http://packages.icinga.org/openSUSE/), [Server Monitoring Repository](https://build.opensuse.org/package/show/server:monitoring/icinga2)
21   SLES                    | [Icinga Repository](http://packages.icinga.org/SUSE/)
22   Gentoo                  | [Upstream](http://packages.gentoo.org/package/net-analyzer/icinga2)
23   FreeBSD                 | [Upstream](http://www.freshports.org/net-mgmt/icinga2)
24   ArchLinux               | [Upstream](https://aur.archlinux.org/packages/icinga2)
25
26 Packages for distributions other than the ones listed above may also be
27 available. Please contact your distribution packagers.
28
29 ### <a id="installing-requirements"></a> Installing Requirements for Icinga 2
30
31 You need to add the Icinga repository to your package management configuration.
32 Below is a list with examples for the various distributions.
33
34 Debian (debmon):
35
36     # wget -O - http://debmon.org/debmon/repo.key 2>/dev/null | apt-key add -
37     # cat >/etc/apt/sources.list.d/debmon.list<<EOF
38     deb http://debmon.org/debmon debmon-wheezy main
39     EOF
40     # apt-get update
41
42 Ubuntu (PPA):
43
44     # add-apt-repository ppa:formorer/icinga
45     # apt-get update
46
47 RHEL/CentOS:
48
49     # rpm --import http://packages.icinga.org/icinga.key
50     # wget http://packages.icinga.org/epel/ICINGA-release.repo -O /etc/yum.repos.d/ICINGA-release.repo
51     # yum makecache
52
53 Fedora:
54
55     # wget http://packages.icinga.org/fedora/ICINGA-release.repo -O /etc/yum.repos.d/ICINGA-release.repo
56     # yum makecache
57
58 SLES:
59
60     # zypper ar http://packages.icinga.org/SUSE/ICINGA-release.repo
61     # zypper ref
62
63 OpenSUSE:
64
65     # zypper ar http://packages.icinga.org/openSUSE/ICINGA-release.repo
66     # zypper ref
67
68 The packages for RHEL/CentOS depend on other packages which are distributed
69 as part of the [EPEL repository](http://fedoraproject.org/wiki/EPEL). Please
70 make sure to enable this repository by following
71 [these instructions](#http://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F).
72
73 ### <a id="installing-icinga2"></a> Installing Icinga 2
74
75 You can install Icinga 2 by using your distribution's package manager
76 to install the `icinga2` package.
77
78 Debian/Ubuntu:
79
80     # apt-get install icinga2
81
82 RHEL/CentOS/Fedora:
83
84     # yum install icinga2
85
86 SLES/OpenSUSE:
87
88     # zypper install icinga2
89
90 On RHEL/CentOS and SLES you will need to use `chkconfig` to enable the
91 `icinga2` service. You can manually start Icinga 2 using `service icinga2 start`.
92
93     # chkconfig icinga2 on
94     # service icinga2 start
95
96 RHEL/CentOS 7 use [Systemd](#systemd-service) with `systemctl {enable,start} icinga2`.
97
98     # systemctl enable icinga2
99     # systemctl start icinga2
100
101 Some parts of Icinga 2's functionality are available as separate packages:
102
103   Name                    | Description
104   ------------------------|--------------------------------
105   icinga2-ido-mysql       | [DB IDO](#configuring-db-ido) provider module for MySQL
106   icinga2-ido-pgsql       | [DB IDO](#configuring-db-ido) provider module for PostgreSQL
107
108 If you're running a distribution for which Icinga 2 packages are
109 not yet available you will need to use the release tarball which you
110 can download from the [Icinga website](https://www.icinga.org/). The
111 release tarballs contain an `INSTALL` file with further instructions.
112
113 ### <a id="installation-enabled-features"></a> Enabled Features during Installation
114
115 The default installation will enable three features required for a basic
116 Icinga 2 installation:
117
118 * `checker` for executing checks
119 * `notification` for sending notifications
120 * `mainlog` for writing the `icinga2.log ` file
121
122 Verify that by calling `icinga2-enable-feature` without any additional parameters
123 and enable the missing features, if any.
124
125     # icinga2-enable-feature
126     Syntax: icinga2-enable-feature <features separated with whitespaces>
127       Example: icinga2-enable-feature checker notification mainlog
128     Enables the specified feature(s).
129
130     Available features: api checker command compatlog debuglog graphite icingastatus ido-mysql ido-pgsql livestatus mainlog notification perfdata statusdata syslog
131     Enabled features: checker mainlog notification
132
133 ### <a id="installation-paths"></a> Installation Paths
134
135 By default Icinga 2 uses the following files and directories:
136
137   Path                                | Description
138   ------------------------------------|------------------------------------
139   /etc/icinga2                        | Contains Icinga 2 configuration files.
140   /etc/init.d/icinga2                 | The Icinga 2 init script.
141   /usr/bin/icinga2-*                  | Migration and certificate build scripts.
142   /usr/sbin/icinga2*                  | The Icinga 2 binary and feature enable/disable scripts.
143   /usr/share/doc/icinga2              | Documentation files that come with Icinga 2.
144   /usr/share/icinga2/include          | The Icinga Template Library and plugin command configuration.
145   /var/run/icinga2                    | PID file.
146   /var/run/icinga2/cmd                | Command pipe and Livestatus socket.
147   /var/cache/icinga2                  | status.dat/objects.cache.
148   /var/spool/icinga2                  | Used for performance data spool files.
149   /var/lib/icinga2                    | Icinga 2 state file, cluster feature replay log and configuration files.
150   /var/log/icinga2                    | Log file location and compat/ directory for the CompatLogger feature.
151
152 ## <a id="setting-up-check-plugins"></a> Setting up Check Plugins
153
154 Without plugins Icinga 2 does not know how to check external services. The
155 [Monitoring Plugins Project](https://www.monitoring-plugins.org/) provides
156 an extensive set of plugins which can be used with Icinga 2 to check whether
157 services are working properly.
158
159 The recommended way of installing these standard plugins is to use your
160 distribution's package manager.
161
162 > **Note**
163 >
164 > The `Nagios Plugins` project was renamed to `Monitoring Plugins`
165 > in January 2014. At the time of this writing some packages are still
166 > using the old name while some distributions have adopted the new package
167 > name `monitoring-plugins` already.
168
169 > **Note**
170 >
171 > EPEL for RHEL/CentOS 7 is still in beta mode at the time of writing and does
172 > not provide a `monitoring-plugins` package. You are required to manually install
173 > them.
174
175 For your convenience here is a list of package names for some of the more
176 popular operating systems/distributions:
177
178 OS/Distribution        | Package Name       | Installation Path
179 -----------------------|--------------------|---------------------------
180 RHEL/CentOS (EPEL)     | nagios-plugins-all | /usr/lib/nagios/plugins or /usr/lib64/nagios/plugins
181 Debian                 | nagios-plugins     | /usr/lib/nagios/plugins
182 FreeBSD                | nagios-plugins     | /usr/local/libexec/nagios
183 OS X (MacPorts)        | nagios-plugins     | /opt/local/libexec
184
185 Depending on which directory your plugins are installed into you may need to
186 update the global `PluginDir` constant in your Icinga 2 configuration. This macro is used
187 by the service templates contained in the Icinga Template Library to determine
188 where to find the plugin binaries.
189
190 ### <a id="integrate-additional-plugins"></a> Integrate Additional Plugins
191
192 For some services you may need additional 'check plugins' which are not provided
193 by the official Monitoring Plugins project.
194
195 All existing Nagios or Icinga 1.x plugins work with Icinga 2. Here's a
196 list of popular community sites which host check plugins:
197
198 * [MonitoringExchange](https://www.monitoringexchange.org)
199 * [Icinga Wiki](https://wiki.icinga.org)
200
201 The recommended way of setting up these plugins is to copy them to a common directory
202 and create an extra global constant, e.g. `CustomPluginDir` in your [constants.conf](#constants-conf)
203 configuration file:
204
205     # cp check_snmp_int.pl /opt/plugins
206     # chmod +x /opt/plugins/check_snmp_int.pl
207
208     # cat /etc/icinga2/constants.conf
209     /**
210      * This file defines global constants which can be used in
211      * the other configuration files. At a minimum the
212      * PluginDir constant should be defined.
213      */
214
215     const PluginDir = "/usr/lib/nagios/plugins"
216     const CustomPluginDir = "/opt/monitoring"
217
218 Prior to using the check plugin with Icinga 2 you should ensure that it is working properly
219 by trying to run it on the console using whichever user Icinga 2 is running as:
220
221     # su - icinga -s /bin/bash
222     $ /opt/plugins/check_snmp_int.pl --help
223
224 Additional libraries may be required for some plugins. Please consult the plugin
225 documentation and/or plugin provided README for installation instructions.
226
227 Each plugin requires a [CheckCommand](#objecttype-checkcommand) object in your
228 configuration which can be used in the [Service](#objecttype-service) or
229 [Host](#objecttype-host) object definition. Examples for `CheckCommand`
230 objects can be found in the [Plugin Check Commands](#plugin-check-commands) shipped
231 with Icinga 2.
232 For further information on your monitoring configuration read the
233 [monitoring basics](#monitoring-basics).
234
235
236 ## <a id="configuring-icinga2-first-steps"></a> Configuring Icinga 2: First Steps
237
238 ### <a id="icinga2-conf"></a> icinga2.conf
239
240 An example configuration file is installed for you in `/etc/icinga2/icinga2.conf`.
241
242 Here's a brief description of the example configuration:
243
244     /**
245      * Icinga 2 configuration file
246      * - this is where you define settings for the Icinga application including
247      * which hosts/services to check.
248      *
249      * For an overview of all available configuration options please refer
250      * to the documentation that is distributed as part of Icinga 2.
251      */
252
253 Icinga 2 supports [C/C++-style comments](#comments).
254
255     /**
256      * The constants.conf defines global constants.
257      */
258     include "constants.conf"
259
260 The `include` directive can be used to include other files.
261
262     /**
263      * The zones.conf defines zones for a cluster setup.
264      * Not required for single instance setups.
265      */
266      include "zones.conf"
267
268     /**
269      * The Icinga Template Library (ITL) provides a number of useful templates
270      * and command definitions.
271      * Common monitoring plugin command definitions are included separately.
272      */
273     include <itl>
274     include <plugins>
275
276     /**
277      * The features-available directory contains a number of configuration
278      * files for features which can be enabled and disabled using the
279      * icinga2-enable-feature / icinga2-disable-feature tools. These two tools work by creating
280      * and removing symbolic links in the features-enabled directory.
281      */
282     include "features-enabled/*.conf"
283
284 This `include` directive takes care of including the configuration files for all
285 the features which have been enabled with `icinga2-enable-feature`. See
286 [Enabling/Disabling Features](#features) for more details.
287
288     /**
289      * Although in theory you could define all your objects in this file
290      * the preferred way is to create separate directories and files in the conf.d
291      * directory. Each of these files must have the file extension ".conf".
292      */
293     include_recursive "conf.d"
294
295 You can put your own configuration files in the `conf.d` directory. This
296 directive makes sure that all of your own configuration files are included.
297
298 ### <a id="constants-conf"></a> constants.conf
299
300 The `constants.conf` configuration file can be used to define global constants:
301
302     /**
303      * This file defines global constants which can be used in
304      * the other configuration files.
305      */
306
307     /* The directory which contains the plugins from the Monitoring Plugins project. */
308     const PluginDir = "/usr/lib/nagios/plugins"
309
310     /* Our local instance name. This should be the common name from the API certificate */
311     const NodeName = "localhost"
312
313     /* Our local zone name. */
314     const ZoneName = NodeName
315
316 ### <a id="zones-conf"></a> zones.conf
317
318 The `zones.conf` configuration file can be used to configure `Endpoint` and `Zone` objects
319 required for a [distributed zone setup](#distributed-monitoring-high-availability). By default
320 a local dummy zone is defined based on the `NodeName` constant defined in
321 [constants.conf](#constants-conf).
322
323 > **Note**
324 >
325 > Not required for single instance installations.
326
327
328 ### <a id="localhost-conf"></a> localhost.conf
329
330 The `conf.d/hosts/localhost.conf` file contains our first host definition:
331
332     /**
333      * A host definition. You can create your own configuration files
334      * in the conf.d directory (e.g. one per host). By default all *.conf
335      * files in this directory are included.
336      */
337
338     object Host "localhost" {
339       import "generic-host"
340
341       address = "127.0.0.1"
342       address6 = "::1"
343
344       vars.os = "Linux"
345       vars.sla = "24x7"
346     }
347
348 This defines the host `localhost`. The `import` keyword is used to import
349 the `generic-host` template which takes care of setting up the host check
350 command to `hostalive`. If you require a different check command, you can
351 override it in the object definition.
352
353 The `vars` attribute can be used to define custom attributes which are available
354 for check and notification commands. Most of the templates in the Icinga
355 Template Library require an `address` attribute.
356
357 The custom attribute `os` is evaluated by the `linux-servers` group in
358 `groups.conf `making the host `localhost` a member.
359
360     object HostGroup "linux-servers" {
361       display_name = "Linux Servers"
362
363       assign where host.vars.os == "Linux"
364     }
365
366 A host notification apply rule in `notifications.conf` checks for the custom
367 attribute `sla` being set to `24x7` automatically applying a host notification.
368
369     /**
370      * The example notification apply rules.
371      *
372      * Only applied if host/service objects have
373      * the custom attribute `sla` set to `24x7`.
374      */
375
376     apply Notification "mail-icingaadmin" to Host {
377       import "mail-host-notification"
378
379       user_groups = [ "icingaadmins" ]
380
381       assign where host.vars.sla == "24x7"
382     }
383
384 Now it's time to define services for the host object. Because these checks
385 are only available for the `localhost` host, they are organized below
386 `hosts/localhost/`.
387
388 > **Tip**
389 >
390 > The directory tree and file organisation is just an example. You are
391 > free to define your own strategy. Just keep in mind to include the
392 > main directories in the [icinga2.conf](#icinga2-conf) file.
393
394     object Service "disk" {
395       import "generic-service"
396
397       host_name = "localhost"
398       check_command = "disk"
399       vars.sla = "24x7"
400     }
401
402     object Service "http" {
403       import "generic-service"
404
405       host_name = "localhost"
406       check_command = "http"
407       vars.sla = "24x7"
408     }
409
410     object Service "load" {
411       import "generic-service"
412
413       host_name = "localhost"
414       check_command = "load"
415       vars.sla = "24x7"
416     }
417
418     object Service "procs" {
419       import "generic-service"
420
421       host_name = "localhost"
422       check_command = "procs"
423       vars.sla = "24x7"
424     }
425
426     object Service "ssh" {
427       import "generic-service"
428
429       host_name = "localhost"
430       check_command = "ssh"
431       vars.sla = "24x7"
432     }
433
434     object Service "swap" {
435       import "generic-service"
436
437       host_name = "localhost"
438       check_command = "swap"
439       vars.sla = "24x7"
440     }
441
442     object Service "users" {
443       import "generic-service"
444
445       host_name = "localhost"
446       check_command = "users"
447       vars.sla = "24x7"
448     }
449
450     object Service "icinga" {
451       import "generic-service"
452
453       host_name = "localhost"
454       check_command = "icinga"
455       vars.sla = "24x7"
456     }
457
458 The command object `icinga` for the embedded health check is provided by the
459 [Icinga Template Library (ITL)](#itl) while `http_ip`, `ssh`, `load`, `processes`,
460 `users` and `disk` are all provided by the plugin check commands which we enabled
461 earlier by including the `itl` and `plugins` configuration file.
462
463 The Debian packages also ship an additional `apt` service check.
464
465 > **Best Practice**
466 >
467 > Instead of defining each service object and assigning it to a host object
468 > using the `host_name` attribute rather use the [apply rules](#apply)
469 > simplifying your configuration.
470
471 There are two generic services applied to all hosts in the host group `linux-servers`
472 and `windows-servers` by default: `ping4` and `ping6`. Host objects without
473 a valid `address` resp. `address6` attribute will be excluded.
474
475     apply Service "ping4" {
476       import "generic-service"
477
478       check_command = "ping4"
479       vars.sla = "24x7"
480
481       assign where "linux-servers" in host.groups
482       assign where "windows-servers" in host.groups
483       ignore where host.address == ""
484     }
485
486     apply Service "ping6" {
487       import "generic-service"
488
489       check_command = "ping6"
490       vars.sla = "24x7"
491
492       assign where "linux-servers" in host.groups
493       assign where "windows-servers" in host.groups
494       ignore where host.address6 == ""
495     }
496
497 Each of these services has the custom attribute `sla` set to `24x7`. The
498 notification apply rule in `notifications.conf` will automatically apply
499 a service notification matchting this attribute pattern.
500
501     apply Notification "mail-icingaadmin" to Service {
502       import "mail-service-notification"
503
504       user_groups = [ "icingaadmins" ]
505
506       assign where service.vars.sla == "24x7"
507     }
508
509 Don't forget to install the [check plugins](#setting-up-check-plugins) required by the services and
510 their check commands.
511
512 Further details on the monitoring configuration can be found in the
513 [monitoring basics](#monitoring-basics) chapter.
514
515 ## <a id="configuring-db-ido"></a> Configuring DB IDO
516
517 The DB IDO (Database Icinga Data Output) modules for Icinga 2 take care of exporting
518 all configuration and status information into a database. The IDO database is used
519 by a number of projects including Icinga Web 1.x, Reporting or Icinga Web 2.
520
521 There is a separate module for each database back-end. At present support for
522 both MySQL and PostgreSQL is implemented.
523
524 Icinga 2 uses the Icinga 1.x IDOUtils database schema. Icinga 2 requires additional
525 features not yet released with older Icinga 1.x versions.
526
527 > **Note**
528 >
529 > Please check the [what's new](#whats-new) section for the required schema version.
530
531 > **Tip**
532 >
533 > Only install the IDO feature if your web interface or reporting tool requires
534 > you to do so (for example, [Icinga Web](#setting-up-icinga-web) or [Icinga Web 2](#setting-up-icingaweb2)).
535 > [Icinga Classic UI](#setting-up-icinga-classic-ui) does not use IDO as backend.
536
537 ### <a id="installing-database"></a> Installing the Database Server
538
539 In order to use DB IDO you need to setup either [MySQL](#installing-database-mysql-server)
540 or [PostgreSQL](#installing-database-postgresql-server) as supported database server.
541
542 > **Note**
543 >
544 > It's up to you whether you choose to install it on the same server where Icinga 2 is running on,
545 > or on a dedicated database host (or cluster).
546
547 #### <a id="installing-database-mysql-server"></a> Installing MySQL database server
548
549 Debian/Ubuntu:
550
551     # apt-get install mysql-server mysql-client
552
553 RHEL/CentOS 5/6:
554
555     # yum install mysql-server mysql
556     # chkconfig mysqld on
557     # service mysqld start
558
559 RHEL/CentOS 7 and Fedora 20 prefer MariaDB over MySQL:
560
561     # yum install mariadb-server mariadb
562     # systemctl enable mariadb.service
563     # systemctl start mariadb.service
564
565 SUSE:
566
567     # zypper install mysql mysql-client
568     # chkconfig mysqld on
569     # service mysqld start
570
571 RHEL based distributions do not automatically set a secure root password. Do that **now**:
572
573     # /usr/bin/mysql_secure_installation
574
575
576 #### <a id="installing-database-postgresql-server"></a> Installing PostgreSQL database server
577
578 Debian/Ubuntu:
579
580     # apt-get install postgresql
581
582 RHEL/CentOS 5/6:
583
584     # yum install postgresql-server postgresql
585     # chkconfig postgresql on
586     # service postgresql start
587
588 RHEL/CentOS 7 and Fedora 20 use [systemd](#systemd-service):
589
590     # yum install postgresql-server postgresql
591     # systemctl enable postgresql.service
592     # systemctl start postgresql.service
593
594 SUSE:
595
596     # zypper install postgresql postgresql-server
597     # chkconfig postgresql on
598     # service postgresql start
599
600 ### <a id="configuring-db-ido-mysql"></a> Configuring DB IDO MySQL
601
602 First of all you have to install the `icinga2-ido-mysql` package using your
603 distribution's package manager.
604
605 Debian/Ubuntu:
606
607     # apt-get install icinga2-ido-mysql
608
609 RHEL/CentOS:
610
611     # yum install icinga2-ido-mysql
612
613 SUSE:
614
615     # zypper install icinga2-ido-mysql
616
617
618
619 > **Note**
620 >
621 > Upstream Debian packages provide a database configuration wizard by default.
622 > You can skip the automated setup and install/upgrade the database manually
623 > if you prefer that.
624
625 #### <a id="setting-up-mysql-db"></a> Setting up the MySQL database
626
627 Set up a MySQL database for Icinga 2:
628
629     # mysql -u root -p
630
631     mysql>  CREATE DATABASE icinga;
632             GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY 'icinga';
633             quit
634
635 After creating the database you can import the Icinga 2 IDO schema using the
636 following command:
637
638     # mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/mysql.sql
639
640
641 #### <a id="upgrading-mysql-db"></a> Upgrading the MySQL database
642
643 Check the `/usr/share/icinga2-ido-mysql/schema/upgrade` directory for an
644 incremental schema upgrade file.
645
646 > **Note**
647 >
648 > If there isn't an upgrade file for your current version available there's nothing to do.
649
650 Apply all database schema upgrade files incrementially.
651
652     # mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/upgrade/<version>.sql
653
654 The Icinga 2 DB IDO module will check for the required database schema version on startup
655 and generate an error message if not satisfied.
656
657
658 **Example:** You are upgrading Icinga 2 from version `2.0.2` to `2.1.0`. Look into
659 the *upgrade* directory:
660
661     $ ls /usr/share/icinga2-ido-mysql/schema/upgrade/
662     2.0.2.sql  2.1.0.sql
663
664 There is a new upgrade file called `2.1.0.sql` which must be applied to your IDO database.
665
666
667 #### <a id="installing-ido-mysql"></a> Installing the IDO MySQL module
668
669 The package provides a new configuration file that is installed in
670 `/etc/icinga2/features-available/ido-mysql.conf`. You will need to update the
671 database credentials in this file.
672
673 You can enable the `ido-mysql` feature configuration file using `icinga2-enable-feature`:
674
675     # icinga2-enable-feature ido-mysql
676     Module 'ido-mysql' was enabled.
677     Make sure to restart Icinga 2 for these changes to take effect.
678
679 After enabling the ido-mysql feature you have to restart Icinga 2:
680
681 Debian/Ubuntu, RHEL/CentOS 6 and SUSE:
682
683     # service icinga2 restart
684
685 RHEL/CentOS 7 and Fedora 20:
686
687     # systemctl restart icinga2.service
688
689 ### <a id="configuring-db-ido-postgresql"></a> Configuring DB IDO PostgreSQL
690
691 First of all you have to install the `icinga2-ido-pgsql` package using your
692 distribution's package manager.
693
694 Debian/Ubuntu:
695
696     # apt-get install icinga2-ido-pgsql
697
698 RHEL/CentOS:
699
700     # yum install icinga2-ido-pgsql
701
702 SUSE:
703
704     # zypper install icinga2-ido-pgsql
705
706 > **Note**
707 >
708 > Upstream Debian packages provide a database configuration wizard by default.
709 > You can skip the automated setup and install/upgrade the database manually
710 > if you prefer that.
711
712 #### Setting up the PostgreSQL database
713
714 Set up a PostgreSQL database for Icinga 2:
715
716     # cd /tmp
717     # sudo -u postgres psql -c "CREATE ROLE icinga WITH LOGIN PASSWORD 'icinga'";
718     # sudo -u postgres createdb -O icinga -E UTF8 icinga
719     # sudo -u postgres createlang plpgsql icinga
720
721 > **Note**
722 >
723 > Using PostgreSQL 9.x you can omit the `createlang` command.
724
725 Locate your pg_hba.conf (Debian: `/etc/postgresql/*/main/pg_hba.conf`,
726 RHEL/SUSE: `/var/lib/pgsql/data/pg_hba.conf`), add the icinga user with md5
727 authentication method and restart the postgresql server.
728
729     # vim /var/lib/pgsql/data/pg_hba.conf
730
731     # icinga
732     local   icinga      icinga                            md5
733     host    icinga      icinga      127.0.0.1/32          md5
734     host    icinga      icinga      ::1/128               md5
735
736     # "local" is for Unix domain socket connections only
737     local   all         all                               ident
738     # IPv4 local connections:
739     host    all         all         127.0.0.1/32          ident
740     # IPv6 local connections:
741     host    all         all         ::1/128               ident
742
743     # /etc/init.d/postgresql restart
744
745
746 After creating the database and permissions you can import the Icinga 2 IDO schema
747 using the following command:
748
749     # export PGPASSWORD=icinga
750     # psql -U icinga -d icinga < /usr/share/icinga2-ido-pgsql/schema/pgsql.sql
751
752 #### <a id="upgrading-postgresql-db"></a> Upgrading the PostgreSQL database
753
754 Check the `/usr/share/icinga2-ido-pgsql/schema/upgrade` directory for an
755 incremental schema upgrade file.
756
757 > **Note**
758 >
759 > If there isn't an upgrade file for your current version available there's nothing to do.
760
761 Apply all database schema upgrade files incrementially.
762
763     # export PGPASSWORD=icinga
764     # psql -U icinga -d icinga < /usr/share/icinga2-ido-pgsql/schema/upgrade/<version>.sql
765
766 The Icinga 2 DB IDO module will check for the required database schema version on startup
767 and generate an error message if not satisfied.
768
769 **Example:** You are upgrading Icinga 2 from version `2.0.2` to `2.1.0`. Look into
770 the *upgrade* directory:
771
772     $ ls /usr/share/icinga2-ido-pgsql/schema/upgrade/
773     2.0.2.sql  2.1.0.sql
774
775 There is a new upgrade file called `2.1.0.sql` which must be applied to your IDO database.
776
777
778 #### <a id="installing-ido-postgresql"></a> Installing the IDO PostgreSQL module
779
780 The package provides a new configuration file that is installed in
781 `/etc/icinga2/features-available/ido-pgsql.conf`. You will need to update the
782 database credentials in this file.
783
784 You can enable the `ido-pgsql` feature configuration file using `icinga2-enable-feature`:
785
786     # icinga2-enable-feature ido-pgsql
787     Module 'ido-pgsql' was enabled.
788     Make sure to restart Icinga 2 for these changes to take effect.
789
790 After enabling the ido-pgsql feature you have to restart Icinga 2:
791
792 Debian/Ubuntu, RHEL/CentOS 6 and SUSE:
793
794     # service icinga2 restart
795
796 RHEL/CentOS 7 and Fedora 20:
797
798     # systemctl restart icinga2.service
799
800
801 ### <a id="setting-up-external-command-pipe"></a> Setting Up External Command Pipe
802
803 Web interfaces and other Icinga addons are able to send commands to
804 Icinga 2 through the external command pipe.
805
806 You can enable the External Command Pipe using icinga2-enable-feature:
807
808     # icinga2-enable-feature command
809
810 After that you will have to restart Icinga 2:
811
812 Debian/Ubuntu, RHEL/CentOS 6 and SUSE:
813
814     # service icinga2 restart
815
816 RHEL/CentOS 7 and Fedora 20:
817
818     # systemctl restart icinga2.service
819
820 By default the command pipe file is owned by the group `icingacmd` with read/write
821 permissions. Add your webserver's user to the group `icingacmd` to
822 enable sending commands to Icinga 2 through your web interface:
823
824     # usermod -G -a icingacmd www-data
825
826 Debian packages use `nagios` as the default user and group name. Therefore change `icingacmd` to
827 `nagios`. The webserver's user is different between distributions as well.
828
829 Change "www-data" to the user you're using to run queries.
830
831 > **Note**
832 >
833 > Packages will do that automatically. Verify that by running `id <your-webserver-user>` and skip this
834 > step.
835
836 ## <a id="setting-up-livestatus"></a> Setting up Livestatus
837
838 The [MK Livestatus](http://mathias-kettner.de/checkmk_livestatus.html) project
839 implements a query protocol that lets users query their Icinga instance for
840 status information. It can also be used to send commands.
841
842 > **Tip**
843 >
844 > Only install the Livestatus feature if your web interface or addon requires
845 > you to do so (for example, [Icinga Web 2](#setting-up-icingaweb2)).
846 > [Icinga Classic UI](#setting-up-icinga-classic-ui) and [Icinga Web](#setting-up-icinga-web)
847 > do not use Livestatus as backend.
848
849 The Livestatus component that is distributed as part of Icinga 2 is a
850 re-implementation of the Livestatus protocol which is compatible with MK
851 Livestatus.
852
853 Details on the available tables and attributes with Icinga 2 can be found
854 in the [Livestatus Schema](#schema-livestatus) section.
855
856 You can enable Livestatus using icinga2-enable-feature:
857
858     # icinga2-enable-feature livestatus
859
860 After that you will have to restart Icinga 2:
861
862 Debian/Ubuntu, RHEL/CentOS 6 and SUSE:
863
864     # service icinga2 restart
865
866 RHEL/CentOS 7 and Fedora 20:
867
868     # systemctl restart icinga2.service
869
870 By default the Livestatus socket is available in `/var/run/icinga2/cmd/livestatus`.
871
872 In order for queries and commands to work you will need to add your query user
873 (e.g. your web server) to the `icingacmd` group:
874
875     # usermod -a -G icingacmd www-data
876
877 The Debian packages use `nagios` as the user and group name. Make sure to change `icingacmd` to
878 `nagios` if you're using Debian.
879
880 Change "www-data" to the user you're using to run queries.
881
882 In order to use the historical tables provided by the livestatus feature (for example, the
883 `log` table) you need to have the `CompatLogger` feature enabled. By default these logs
884 are expected to be in `/var/log/icinga2/compat`. A different path can be set using the
885 `compat_log_path` configuration attribute.
886
887     # icinga2-enable-feature compatlog
888
889 ## <a id="setting-up-icinga2-user-interfaces"></a> Setting up Icinga 2 User Interfaces
890
891 Icinga 2 is compatible with Icinga 1.x user interfaces by providing additional
892 features required as backends.
893
894 Furthermore these interfaces can be used for the newly created `Icinga Web 2`
895 user interface.
896
897 Some interface features will only work in a limited manner due to
898 [compatibility reasons](#differences-1x-2), other features like the
899 statusmap parents are available by dumping the host dependencies as parents.
900 Special restrictions are noted specifically in the sections below.
901
902 > **Tip**
903 >
904 > Choose your preferred interface. There's no need to install [Classic UI](#setting-up-icinga-classic-ui)
905 > if you prefer [Icinga Web](#setting-up-icinga-web) or [Icinga Web 2](#setting-up-icingaweb2) for example.
906
907 ### <a id="icinga2-user-interface-requirements"></a> Requirements
908
909 * Web server (Apache2/Httpd, Nginx, Lighttp, etc)
910 * User credentials
911 * Firewall ports (tcp/80)
912
913 The Debian, RHEL and SUSE packages for Icinga [Classic UI](#setting-up-icinga-classic-ui),
914 [Web](#setting-up-icinga-web) and [Icingaweb 2](#setting-up-icingaweb2) depend on Apache2
915 as web server.
916
917 #### <a id="icinga2-user-interface-webserver"></a> Webserver
918
919 Debian/Ubuntu packages will automatically fetch and install the required packages.
920
921 RHEL/CentOS/Fedora:
922
923     # yum install httpd
924     # chkconfig httpd on && service httpd start
925     ## RHEL7
926     # systemctl enable httpd && systemctl start httpd
927
928 SUSE:
929
930     # zypper install apache2
931     # chkconfig on && service apache2 start
932
933 #### <a id="icinga2-user-interface-firewall-rules"></a> Firewall Rules
934
935 Example:
936
937     # iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
938     # service iptables save
939
940 RHEL/CentOS 7 specific:
941
942     # firewall-cmd --add-service=http
943     # firewall-cmd --permanent --add-service=http
944
945 ### <a id="setting-up-icinga-classic-ui"></a> Setting up Icinga Classic UI
946
947 Icinga 2 can write `status.dat` and `objects.cache` files in the format that
948 is supported by the Icinga 1.x Classic UI. [External commands](#external-commands)
949 (a.k.a. the "command pipe") are also supported. It also supports writing Icinga 1.x
950 log files which are required for the reporting functionality in the Classic UI.
951
952 #### <a id="installing-icinga-classic-ui"></a> Installing Icinga Classic UI
953
954 The Icinga package repository has both Debian and RPM packages. You can install
955 the Classic UI using the following packages:
956
957   Distribution  | Packages
958   --------------|---------------------
959   Debian        | icinga2-classicui
960   RHEL/SUSE     | icinga2-classicui-config icinga-gui
961
962 The Debian packages require additional packages which are provided by the
963 [Debian Monitoring Project](http://www.debmon.org) (`DebMon`) repository.
964
965 `libjs-jquery-ui` requires at least version `1.10.*` which is not available
966 in Debian Wheezy and Ubuntu 12.04 LTS (Precise). Add the following repositories
967 to satisfy this dependency:
968
969   Distribution                  | Package Repositories
970   ------------------------------|------------------------------
971   Debian Wheezy                 | [wheezy-backports](http://backports.debian.org/Instructions/) or [DebMon](http://www.debmon.org)
972   Ubuntu 12.04 LTS (Precise)    | [Icinga PPA](https://launchpad.net/~formorer/+archive/icinga)
973
974 On all distributions other than Debian you may have to restart both your web
975 server as well as Icinga 2 after installing the Classic UI package.
976
977 Icinga Classic UI requires the [StatusDataWriter](#status-data), [CompatLogger](#compat-logging)
978 and [ExternalCommandListener](#external-commands) features.
979 Enable these features and restart Icinga 2.
980
981     # icinga2-enable-feature statusdata compatlog command
982
983 In order for commands to work you will need to [setup the external command pipe](#setting-up-external-command-pipe).
984
985 #### <a id="setting-up-icinga-classic-ui-summary"></a> Setting Up Icinga Classic UI Summary
986
987 Verify that your Icinga 1.x Classic UI works by browsing to your Classic
988 UI installation URL:
989
990   Distribution  | URL                                                                      | Default Login
991   --------------|--------------------------------------------------------------------------|--------------------------
992   Debian        | [http://localhost/icinga2-classicui](http://localhost/icinga2-classicui) | asked during installation
993   all others    | [http://localhost/icinga](http://localhost/icinga)                       | icingaadmin/icingaadmin
994
995 For further information on configuration, troubleshooting and interface documentation
996 please check the official [Icinga 1.x user interface documentation](http://docs.icinga.org/latest/en/ch06.html).
997
998 ### <a id="setting-up-icinga-web"></a> Setting up Icinga Web
999
1000 Icinga 2 can write to the same schema supplied by `Icinga IDOUtils 1.x` which
1001 is an explicit requirement to run `Icinga Web` next to the external command pipe.
1002 Therefore you need to setup the [DB IDO feature](#configuring-ido) remarked in the previous sections.
1003
1004 #### <a id="installing-icinga-web"></a> Installing Icinga Web
1005
1006 The Icinga package repository has both Debian and RPM packages. You can install
1007 Icinga Web using the following packages (RPMs ship an additional configuration package):
1008
1009   Distribution  | Packages
1010   --------------|-------------------------------------------------------
1011   RHEL/SUSE     | icinga-web icinga-web-{mysql,pgsql}
1012   Debian        | icinga-web icinga-web-config-icinga2-ido-{mysql,pgsql}
1013
1014 #### <a id="icinga-web-rpm-notes"></a> Icinga Web on RPM based systems
1015
1016 Additionally you need to setup the `icinga_web` database and import the database schema.
1017 Details can be found in the package `README` files, for example [README.RHEL](https://github.com/Icinga/icinga-web/blob/master/doc/README.RHEL)
1018
1019 The Icinga Web RPM packages install the schema files into
1020 `/usr/share/doc/icinga-web-*/schema` (`*` means package version).
1021 The Icinga Web dist tarball ships the schema files in `etc/schema`.
1022
1023 On SuSE-based distributions the schema files are installed in
1024 `/usr/share/doc/packages/icinga-web/schema`.
1025
1026 Example for RHEL and MySQL:
1027
1028     # mysql -u root -p
1029
1030     mysql> CREATE DATABASE icinga_web;
1031            GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga_web.* TO 'icinga_web'@'localhost' IDENTIFIED BY 'icinga_web';
1032            quit
1033
1034     # mysql -u root -p icinga_web <  /usr/share/doc/icinga-web-<version>/schema/mysql.sql
1035
1036 Icinga Web requires the IDO feature as database backend using MySQL or PostgreSQL.
1037 Enable that feature, e.g. for MySQL.
1038
1039     # icinga2-enable-feature ido-mysql
1040
1041 If you've changed your default credentials you may either create a read-only user
1042 or use the credentials defined in the IDO feature for Icinga Web backend configuration.
1043 Edit `databases.xml` accordingly and clear the cache afterwards. Further details can be
1044 found in the [Icinga Web documentation](http://docs.icinga.org/latest/en/icinga-web-config.html).
1045
1046     # vim /etc/icinga-web/conf.d/databases.xml
1047
1048     # icinga-web-clearcache
1049
1050 Additionally you need to enable the `command` feature for sending [external commands](#external-commands):
1051
1052     # icinga2-enable-feature command
1053
1054 In order for commands to work you will need to [setup the external command pipe](#setting-up-external-command-pipe).
1055
1056 Then edit the Icinga Web configuration for sending commands in `/etc/icinga-web/conf.d/access.xml`
1057 (RHEL) or `/etc/icinga-web/access.xml` (SUSE) setting the command pipe path
1058 to the default used in Icinga 2. Make sure to clear the cache afterwards.
1059
1060     # vim /etc/icinga-web/conf.d/access.xml
1061
1062                 <write>
1063                     <files>
1064                         <resource name="icinga_pipe">/var/run/icinga2/cmd/icinga2.cmd</resource>
1065                     </files>
1066                 </write>
1067
1068     # icinga-web-clearcache
1069
1070 > **Note**
1071 >
1072 > The path to the Icinga Web `clearcache` script may differ. Please check the
1073 > [Icinga Web documentation](https://docs.icinga.org) for details.
1074
1075 #### <a id="icinga-web-debian-notes"></a> Icinga Web on Debian systems
1076
1077 Since Icinga Web 1.11.1-2 on Debian and Ubuntu, the IDO autoconfiguration has been moved to additional packages.
1078
1079 The package `icinga-web` no longer configures the IDO connection, you can use one of the config packages:
1080
1081  - `icinga-web-config-icinga2-ido-mysql`
1082  - `icinga-web-config-icinga2-ido-pgsql`
1083
1084 These packages take care of setup up the IDO connection, enabling the command pipe from Icinga Web
1085 and depend on the corresponding packages of Icinga 2.
1086
1087 Please read the README.Debian files for details and how to do advanced configuration:
1088
1089  - `/usr/share/doc/icinga-web/README.Debian`
1090  - `/usr/share/doc/icinga-web-config-icinga2-ido-mysql/README.Debian`
1091  - `/usr/share/doc/icinga-web-config-icinga2-ido-pgsql/README.Debian`
1092
1093 If you change the XML configuration of Icinga Web, make sure to clear the config cache:
1094
1095     # /usr/lib/icinga-web/bin/clearcache.sh
1096
1097 > **Note**
1098 >
1099 > When you use an older version of icinga-web you should install it with:
1100 > `apt-get install --no-install-recommends icinga-web`
1101
1102 #### <a id="setting-up-icinga-web-summary"></a> Setting Up Icinga Web Summary
1103
1104 Verify that your Icinga 1.x Web works by browsing to your Web installation URL:
1105
1106   Distribution  | URL                                                         | Default Login
1107   --------------|-------------------------------------------------------------|--------------------------
1108   Debian        | [http://localhost/icinga-web](http://localhost/icinga-web)  | asked during installation
1109   all others    | [http://localhost/icinga-web](http://localhost/icinga-web)  | root/password
1110
1111 For further information on configuration, troubleshooting and interface documentation
1112 please check the official [Icinga 1.x user interface documentation](http://docs.icinga.org/latest/en/ch06.html).
1113
1114
1115 ### <a id="setting-up-icingaweb2"></a> Setting up Icinga Web 2
1116
1117 Icinga Web 2 will support `status.dat`, `DB IDO`, or `Livestatus` as backends.
1118
1119 Using DB IDO as backend, you need to install and configure the [DB IDO backend](#configuring-db-ido).
1120 Once finished, you can enable the feature for DB IDO MySQL:
1121
1122     # icinga2-enable-feature ido-mysql
1123
1124 Furthermore [external commands](#external-commands) are supported through the external
1125 command pipe.
1126
1127     # icinga2-enable-feature command
1128
1129 In order for commands to work you will need to [setup the external command pipe](#setting-up-external-command-pipe).
1130
1131 Please consult the INSTALL documentation shipped with `Icinga Web 2` for
1132 further instructions on how to install Icinga Web 2 and to configure
1133 backends, resources and instances.
1134
1135 > **Note**
1136 >
1137 > Icinga Web 2 is still under heavy development. Rather than installing it
1138 > yourself you should consider testing it using the available Vagrant
1139 > demo VM in the [git repository](https://github.com/icinga/icingaweb2).
1140
1141 Check the [Icinga website](https://www.icinga.org) for release schedules,
1142 blog updates and more.
1143
1144
1145 ### <a id="additional-visualization"></a> Additional visualization
1146
1147 There are many visualization addons which can be used with Icinga 2.
1148
1149 Some of the more popular ones are [PNP](#addons-graphing-pnp), [inGraph](#addons-graphing-pnp)
1150 graphing performance data), [Graphite](#addons-graphing-pnp), and
1151 [NagVis](#addons-visualization-nagvis) (network maps).
1152
1153
1154 ## <a id="configuration-tools"></a> Configuration Tools
1155
1156 If you require your favourite configuration tool to export Icinga 2 configuration, please get in
1157 touch with their developers. The Icinga project does not provide a configuration web interface
1158 or similar.
1159
1160 > **Tip**
1161 >
1162 > Get to know the new configuration format and the advanced [apply](#using-apply) rules and
1163 > use [syntax highlighting](#configuration-syntax-highlighting) in vim/nano.
1164
1165 If you're looking for puppet manifests, chef cookbooks, ansible recipes, etc - we're happy
1166 to integrate them upstream, so please get in touch at [https://support.icinga.org](https://support.icinga.org).
1167
1168 These tools are in development and require feedback and tests:
1169
1170 * [Ansible Roles](https://github.com/Icinga/icinga2-ansible)
1171 * [Puppet Module](https://github.com/Icinga/puppet-icinga2)
1172
1173 ## <a id="configuration-syntax-highlighting"></a> Configuration Syntax Highlighting
1174
1175 Icinga 2 ships configuration examples for syntax highlighting using the `vim` and `nano`editors.
1176 The RHEL, SUSE and Debian package `icinga2-common` install these files into
1177 `/usr/share/*/icinga2-common/syntax`. Sources provide these files in `tools/syntax`.
1178
1179 ### <a id="configuration-syntax-highlighting-vim"></a> Configuration Syntax Highlighting using Vim
1180
1181 Create a new local vim configuration storage, if not already existing.
1182 Edit `vim/ftdetect/icinga2.vim` if your paths to the Icinga 2 configuration
1183 differ.
1184
1185     $ PREFIX=~/.vim
1186     $ mkdir -p $PREFIX/{syntax,ftdetect}
1187     $ cp vim/syntax/icinga2.vim $PREFIX/syntax/
1188     $ cp vim/ftdetect/icinga2.vim $PREFIX/ftdetect/
1189
1190 Test it:
1191
1192     $ vim /etc/icinga2/conf.d/templates.conf
1193
1194 ### <a id="configuration-syntax-highlighting-nano"></a> Configuration Syntax Highlighting using Nano
1195
1196 Copy the `/etc/nanorc` sample file to your home directory. Create the `/etc/nano` directory
1197 and copy the provided `icinga2.nanorc` into it.
1198
1199     $ cp /etc/nanorc ~/.nanorc
1200
1201     # mkdir -p /etc/nano
1202     # cp icinga2.nanorc /etc/nano/
1203
1204 Then include the icinga2.nanorc file in your ~/.nanorc by adding the following line:
1205
1206     $ vim ~/.nanorc
1207
1208     ## Icinga 2
1209     include "/etc/nano/icinga2.nanorc"
1210
1211 Test it:
1212
1213     $ nano /etc/icinga2/conf.d/templates.conf
1214
1215
1216 ## <a id="running-icinga2"></a> Running Icinga 2
1217
1218 ### <a id="init-script"></a> Init Script
1219
1220 Icinga 2's init script is installed in `/etc/init.d/icinga2` by default:
1221
1222     # /etc/init.d/icinga2
1223     Usage: /etc/init.d/icinga2 {start|stop|restart|reload|checkconfig|status}
1224
1225   Command             | Description
1226   --------------------|------------------------
1227   start               | The `start` action starts the Icinga 2 daemon.
1228   stop                | The `stop` action stops the Icinga 2 daemon.
1229   restart             | The `restart` action is a shortcut for running the `stop` action followed by `start`.
1230   reload              | The `reload` action sends the `HUP` signal to Icinga 2 which causes it to restart. Unlike the `restart` action `reload` does not wait until Icinga 2 has restarted.
1231   checkconfig         | The `checkconfig` action checks if the `/etc/icinga2/icinga2.conf` configuration file contains any errors.
1232   status              | The `status` action checks if Icinga 2 is running.
1233
1234 By default the Icinga 2 daemon is running as `icinga` user and group
1235 using the init script. Using Debian packages the user and group are set to `nagios`
1236 for historical reasons.
1237
1238 ### <a id="systemd-service"></a> Systemd Service
1239
1240 Modern distributions (Fedora, OpenSUSE, etc.) already use `Systemd` natively. Enterprise-grade
1241 distributions such as RHEL7 changed to `Systemd` recently. Icinga 2 Packages will install the
1242 service automatically.
1243
1244 The Icinga 2 `Systemd` service can be (re)started, reloaded, stopped and also queried for its current status.
1245
1246     # systemctl status icinga2
1247     icinga2.service - Icinga host/service/network monitoring system
1248        Loaded: loaded (/usr/lib/systemd/system/icinga2.service; disabled)
1249        Active: active (running) since Mi 2014-07-23 13:39:38 CEST; 15s ago
1250       Process: 21692 ExecStart=/usr/sbin/icinga2 -c ${ICINGA2_CONFIG_FILE} -d -e ${ICINGA2_ERROR_LOG} -u ${ICINGA2_USER} -g ${ICINGA2_GROUP} (code=exited, status=0/SUCCESS)
1251       Process: 21674 ExecStartPre=/usr/sbin/icinga2-prepare-dirs /etc/sysconfig/icinga2 (code=exited, status=0/SUCCESS)
1252      Main PID: 21727 (icinga2)
1253        CGroup: /system.slice/icinga2.service
1254                └─21727 /usr/sbin/icinga2 -c /etc/icinga2/icinga2.conf -d -e /var/log/icinga2/error.log -u icinga -g icinga --no-stack-rlimit
1255
1256     Jul 23 13:39:38 nbmif icinga2[21692]: [2014-07-23 13:39:38 +0200] information/ConfigItem: Checked 309 Service(s).
1257     Jul 23 13:39:38 nbmif icinga2[21692]: [2014-07-23 13:39:38 +0200] information/ConfigItem: Checked 1 User(s).
1258     Jul 23 13:39:38 nbmif icinga2[21692]: [2014-07-23 13:39:38 +0200] information/ConfigItem: Checked 15 Notification(s).
1259     Jul 23 13:39:38 nbmif icinga2[21692]: [2014-07-23 13:39:38 +0200] information/ConfigItem: Checked 4 ScheduledDowntime(s).
1260     Jul 23 13:39:38 nbmif icinga2[21692]: [2014-07-23 13:39:38 +0200] information/ConfigItem: Checked 1 UserGroup(s).
1261     Jul 23 13:39:38 nbmif icinga2[21692]: [2014-07-23 13:39:38 +0200] information/ConfigItem: Checked 1 IcingaApplication(s).
1262     Jul 23 13:39:38 nbmif icinga2[21692]: [2014-07-23 13:39:38 +0200] information/ConfigItem: Checked 8 Dependency(s).
1263     Jul 23 13:39:38 nbmif systemd[1]: Started Icinga host/service/network monitoring system.
1264
1265 `Systemd` supports the following command actions:
1266
1267   Command             | Description
1268   --------------------|------------------------
1269   start               | The `start` action starts the Icinga 2 daemon.
1270   stop                | The `stop` action stops the Icinga 2 daemon.
1271   restart             | The `restart` action is a shortcut for running the `stop` action followed by `start`.
1272   reload              | The `reload` action sends the `HUP` signal to Icinga 2 which causes it to restart. Unlike the `restart` action `reload` does not wait until Icinga 2 has restarted.
1273   status              | The `status` action checks if Icinga 2 is running.
1274   enable              | The `enable` action enables the service being started at system boot time (similar to `chkconfig`)
1275
1276 If you're stuck with configuration errors, you can manually invoke the [configuration validation](#config-validation).
1277
1278     # systemctl enable icinga2
1279
1280     # systemctl restart icinga2
1281     Job for icinga2.service failed. See 'systemctl status icinga2.service' and 'journalctl -xn' for details.
1282
1283 ### <a id="cmdline"></a> Command-line Options
1284
1285     $ icinga2 --help
1286     icinga2 - The Icinga 2 network monitoring daemon.
1287
1288     Supported options:
1289       --help                show this help message
1290       -V [ --version ]      show version information
1291       -l [ --library ] arg  load a library
1292       -I [ --include ] arg  add include search directory
1293       -D [ --define] args   define a constant
1294       -c [ --config ] arg   parse a configuration file
1295       -C [ --validate ]     exit after validating the configuration
1296       -x [ --debug ] arg    enable debugging with severity level specified
1297       -d [ --daemonize ]    detach from the controlling terminal
1298       -e [ --errorlog ] arg log fatal errors to the specified log file (only works
1299                             in combination with --daemonize)
1300       -u [ --user ] arg     user to run Icinga as
1301       -g [ --group ] arg    group to run Icinga as
1302
1303     Report bugs at <https://dev.icinga.org/>
1304     Icinga home page: <http://www.icinga.org/>
1305
1306 #### Libraries
1307
1308 Instead of loading libraries using the [`library` config directive](#library)
1309 you can also use the `--library` command-line option.
1310
1311 #### Constants
1312
1313 [Global constants](#global-constants) can be set using the `--define` command-line option.
1314
1315 #### Config Include Path
1316
1317 When including files you can specify that the include search path should be
1318 checked. You can do this by putting your configuration file name in angle
1319 brackets like this:
1320
1321     include <test.conf>
1322
1323 This would cause Icinga 2 to search its include path for the configuration file
1324 `test.conf`. By default the installation path for the Icinga Template Library
1325 is the only search directory.
1326
1327 Using the `--include` command-line option additional search directories can be
1328 added.
1329
1330 #### Config Files
1331
1332 Using the `--config` option you can specify one or more configuration files.
1333 Config files are processed in the order they're specified on the command-line.
1334
1335 When no configuration file is specified and the `--no-config` is not used
1336 Icinga 2 automatically falls back to using the configuration file
1337 `SysconfDir + "/icinga2/icinga2.conf"` (where SysconfDir is usually `/etc`).
1338
1339 #### Config Validation
1340
1341 The `--validate` option can be used to check if your configuration files
1342 contain errors. If any errors are found the exit status is 1, otherwise 0
1343 is returned.
1344
1345 ### <a id="features"></a> Enabling/Disabling Features
1346
1347 Icinga 2 provides configuration files for some commonly used features. These
1348 are installed in the `/etc/icinga2/features-available` directory and can be
1349 enabled and disabled using the `icinga2-enable-feature` and `icinga2-disable-feature` tools,
1350 respectively.
1351
1352 The `icinga2-enable-feature` tool creates symlinks in the `/etc/icinga2/features-enabled`
1353 directory which is included by default in the example configuration file.
1354
1355 You can view a list of available feature configuration files:
1356
1357     # icinga2-enable-feature
1358     Syntax: icinga2-enable-feature <feature>
1359     Enables the specified feature.
1360
1361     Available features: statusdata
1362
1363 Using the `icinga2-enable-feature` command you can enable features:
1364
1365     # icinga2-enable-feature statusdata
1366     Module 'statusdata' was enabled.
1367     Make sure to restart Icinga 2 for these changes to take effect.
1368
1369 You can disable features using the `icinga2-disable-feature` command:
1370
1371     # icinga2-disable-feature statusdata
1372     Module 'statusdata' was disabled.
1373     Make sure to restart Icinga 2 for these changes to take effect.
1374
1375 The `icinga2-enable-feature` and `icinga2-disable-feature` commands do not
1376 restart Icinga 2. You will need to restart Icinga 2 using the init script
1377 after enabling or disabling features.
1378
1379 ### <a id="config-validation"></a> Configuration Validation
1380
1381 Once you've edited the configuration files make sure to tell Icinga 2 to validate
1382 the configuration changes. Icinga 2 will log any configuration error including
1383 a hint on the file, the line number and the affected configuration line itself.
1384
1385 The following example creates an apply rule without any `assign` condition.
1386
1387     apply Service "5872-ping4" {
1388       import "test-generic-service"
1389       check_command = "ping4"
1390       //assign where match("5872-*", host.name)
1391     }
1392
1393 Validate the configuration with the init script option `checkconfig`
1394
1395     # /etc/init.d/icinga2 checkconfig
1396
1397 or manually passing the `-C` argument:
1398
1399     # /usr/sbin/icinga2 -c /etc/icinga2/icinga2.conf -C
1400
1401     [2014-05-22 17:07:25 +0200] critical/ConfigItem: Location:
1402     /etc/icinga2/conf.d/tests/5872.conf(5): }
1403     /etc/icinga2/conf.d/tests/5872.conf(6):
1404     /etc/icinga2/conf.d/tests/5872.conf(7): apply Service "5872-ping4" {
1405                                             ^^^^^^^^^^^^^
1406     /etc/icinga2/conf.d/tests/5872.conf(8):   import "test-generic-service"
1407     /etc/icinga2/conf.d/tests/5872.conf(9):   check_command = "ping4"
1408
1409     Config error: 'apply' is missing 'assign'
1410     [2014-05-22 17:07:25 +0200] critical/ConfigItem: 1 errors, 0 warnings.
1411     Icinga 2 detected configuration errors.
1412
1413
1414 ### <a id="config-change-reload"></a> Reload on Configuration Changes
1415
1416 Everytime you have changed your configuration you should first tell  Icinga 2
1417 to [validate](#config-validation). If there are no validation errors you can
1418 safely reload the Icinga 2 daemon.
1419
1420     # /etc/init.d/icinga2 reload
1421
1422 > **Note**
1423 >
1424 > The `reload` action will send the `SIGHUP` signal to the Icinga 2 daemon
1425 > which will validate the configuration in a separate process and not stop
1426 > the other events like check execution, notifications, etc.
1427 >
1428 > Details can be found [here](#differences-1x-2-real-reload).
1429
1430
1431 ## <a id="vagrant"></a> Vagrant Demo VM
1432
1433 The Icinga Vagrant Git repository contains support for [Vagrant](http://docs.vagrantup.com/v2/)
1434 with VirtualBox. Please note that Vagrant version `1.0.x` is not supported. At least
1435 version `1.2.x` is required.
1436
1437 In order to build the Vagrant VM first you will have to check out
1438 the Git repository:
1439
1440     $ git clone git://git.icinga.org/icinga-vagrant.git
1441
1442 For Icinga 2 there are currently two scenarios available:
1443
1444 * `icinga2x` bringing up a standalone box with Icinga 2
1445 * `icinga2x-cluster` setting up two virtual machines in a master/slave cluster
1446
1447 > **Note**
1448 >
1449 > Please consult the `README.md` file for each project for further installation
1450 > details at [https://github.com/Icinga/icinga-vagrant]
1451
1452 Once you have checked out the Git repository navigate to your required
1453 vagrant box and build the VM using the following command:
1454
1455     $ vagrant up
1456
1457 The Vagrant VMs are based on CentOS 6.x and are using the official
1458 Icinga 2 RPM snapshot packages from `packages.icinga.org`. The check
1459 plugins are installed from EPEL providing RPMs with sources from the
1460 Monitoring Plugins project.