Install Icinga2, Icinga Web 2 and Icinga Director under EL7

Download PDF

Icinga2 is a very powerful monitoring system that can be used optionally with the new user interface Icinga Web 2. In comparison with Icinga 1.x, those tools have been developed completely from scratch – they have nothing in common with the legacy software stack.

This year, a configuration utility named Icinga Director has been released. It can be used to configure the whole Icinga2 stack. An intergration into Configuration Management and CMDB systems is also possible.

This article describes the basic installation of a Icinga2 system with the Icinga Web 2 UI and the additional Icinga Director module.


LVM preparation

I prefer to move MySQL databases to a dedicated hard drive with LVM. The following commands will swap out the /var/lib/mysql directory:

# pvcreate /dev/sdb
# vgcreate vg_data /dev/sdb
# lvcreate --name lv_mariadb --size 9G vg_data
# mkfs.ext4 /dev/mapper/vg_data-lv_mariadb
# vi /etc/fstab
/dev/mapper/vg_data-lv_mariadb /var/lib/mysql   ext4   defaults   1 2


# mkdir /var/lib/mysql ; mount -a
# restorecon -v /var/lib/mysql
restorecon reset /var/lib/mysql context system_u:object_r:unlabeled_t:s0->system_u:object_r:mysqld_db_t:s0

Package installation

The packages are installed using YUM – ensure that the EPEL repository is available to your system:

# yum install icinga{,web}2 icinga2-ido-mysql mariadb-server mysql nagios-plugins-all icingacli php-ldap


Afterwards, the Apache web server and MariaDB database are configured and enabled for autostart. At this time it is a good idea to execute mysql_secure_installation in order to configure a root password and remove unused demo content:

# systemctl enable httpd; systemctl start httpd
# systemctl enable mariadb ; systemctl start mariadb
# mysql_secure_installation
Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Afterwards, dedicated databases are created for Icinga and the user authentication:

# mysql -u root -p
mysql> CREATE DATABASE `icinga`;
mysql> CREATE DATABASE `icinga-auth`;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON `icinga-auth`.* TO 'icinga'@'localhost' IDENTIFIED BY '...';

Make sure to import the database schema:

# mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/mysql.sql


Icinga2 is modular and supports altering the feature set by enabling/disabling modules. The following command controls features:

# icinga2 feature list
Disabled features: command compatlog debuglog gelf graphite icingastatus ido-mysql livestatus opentsdb perfdata statusdata syslog
Enabled features: api checker mainlog notification

The commands lists available and enabled features. We need to enable the following features:

  • ido-mysql – MySQL database broker, stores status information, necessary for Icinga Web 2
  • perfdata – captures performance data (e.g. speed of HTTP requests) of monitored services if supported
  • command – enables external commands, necessary for well-known Nagios plugins

After enabling features, Icinga2 needs to be restarted.

# icinga2 feature enable ido-mysql
# icinga2 feature enable perfdata
# icinga2 feature enable command

Before Icinga2 is started for the first time, the IDO broker configuration needs to be altered. Connection information of the Icinga database need to be entered:

# vi /etc/icinga2/features-available/ido-mysql.conf
library "db_ido_mysql"

object IdoMysqlConnection "ido-mysql" {
  user = "icinga"
  password = "xxx"
  host = "localhost"
  database = "icinga"

Another tipp regarding clarity – I decided to create dedicated sub-folders for configuration files. Icinga2 stores all configuration files in the /etc/icinga2/conf.d directory. For bigger installations it might be a good idea to store customized hosts, checks and commands in a dedicated sub-folder. Ensure that these folder is owned by the Icinga user:

# mkdir /etc/icinga2/conf.d/stankowic.d
# chown icinga: /etc/icinga2/conf.d/stankowic.d

Afterwards, Icinga2 can be started and enabled for autostart:

# systemctl enable icinga2 ; systemctl start icinga2

If you are using SELinux, ensure to create and install the appropriate modules:

# yum install icinga2-selinux selinux-policy-devel
# /usr/share/doc/icinga2-selinux-*/

Icinga Web 2

Before Icinga Web 2 can be installed, the local timezone needs to be entered in the PHP configuration, e.g. for Germany:

# cp /etc/php.ini /etc/php.ini.initial
# vi +/date.timezone /etc/php.ini
date.timezone = Europe/Berlin

# systemctl restart httpd

Afterwards, a SELinux flag needs to enabled and the Apache user should be added to the icingacmd group to enable controlling Icinga2:

# setsebool -P httpd_unified 1
# usermod -a -G icingacmd apache

To start the installation, a token needs to be created – it will be used in the installation assistant in the next step. The assistant can be accessed using the URL http://meinServer/icingaweb2/setup:

# icingacli setup config directory --group icingaweb2
# icingacli setup token create
The newly generated setup token is: 95f454f8bde828a3

The installation assistant is kinda self-explanatory and proceeds with the following steps:

  1. Selecting authentication source (database or LDAP)
  2. Configuring the database resource
  3. Creating an administration account
  4. Configuring logging
  5. Configuring the IDO broker

Some screenshots of my installation:

Icinga Director

Icinga Director can be downloaded on GitHub. The source code needs to be extracted in the /usr/share/icingaweb2/modules directory. Ensure that the folder extracted from the archive is renamed to director – otherwise, bad things will happen:

# cd /usr/share/icingaweb2/modules
# wget
# unzip
# mv icingaweb2-module-director-master director
# restorecon -R director

Before enabling the module, a dedicated database including a user is created. It is also necessary to import a database schema:

# mysql -u root -p
mysql> CREATE DATABASE director CHARACTER SET 'utf8';
mysql> GRANT ALL ON director.* TO 'director'@'localhost' IDENTIFIED BY '...';
# mysql -u root -p director < /usr/share/icingaweb2/modules/director/schema/mysql.sql

Icinga Director utilizes the Icinga2 API feature, which needs to be enabled first. During this, certificates used for external applications to bind to Icinga2 are created:

# setsebool -P httpd_can_network_connect 1
# icinga2 api setup

It is necessary to create a API user with full privileges for Icinga Director. Those privileges are necessary as Icinga Director should be able to control the complete Icinga2 instance:

# vi /etc/icinga2/conf.d/api-users.conf
object ApiUser "director" {
        password = "xxx"
        permissions = [ "*" ]


Afterwards, ensure to open TCP port 5665 and restart Icinga2:

# system-config-firewall-tui
# systemctl restart icinga2

The Icinga2 web interface is used in order to enable the module – to proceed, click Configuration > Modules > director > enable in the left menu.

The next step is to start another installation assistent by clicking Icinga Director in the same menu. The assistant proceeds with the following steps:

  1. Configuring the database
  2. Selecting the Icinga2 host and API user

A screenshot of my installation:

Director setup

Director setup

There is only one thing missing: reproducing your infrastructure within Icinga2 – e.g. using Icinga Director! 🙂

Download PDF

Related Articles