Linux, Windows, Virtualization, OpenSource & Blogging

Linux Monitoring Tool: Install Icinga2 on Ubuntu 16.04 / 14.04 , Debian, and Mint


Icinga2 is an open source monitoring tool, a fork of famous Nagios monitoring system. With Icinga2, you will be able to monitor your network resources, get an alert on the outage, also able to generate the performance data.

Icinga 2 is very scalable, and you can monitor small to larger, complex environments across multiple locations. Icinga 2 supports all major distributions such as Debian, Ubuntu, CentOS / RHEL, Fedora, openSUSE, SLES, Gentoo, FreeBSD, and ArchLinux.

This document covers basic installation and configuration of Icinga 2 on Ubuntu 16.04 / Debian 8 / 7, Mint.; this should also work on the previous versions of Ubuntu such as Ubuntu 14.04/14.10/15.04/15.10 and Ubuntu 12.04 LTS.

There are some alternative monitoring tools available to try out, such as Zabbix, Nagios, Cacti, and Monit.

Installing Icinga 2

Icinga provides you the official repository for their packages; you can either use Icinga PPA or Icinga repository.

Switch to the root user.

$ su -

We will use Icinga PPA here, let’s add it by using the following command.

### Ubuntu 16.04/14.04/12.04 / Mint ###

$ sudo add-apt-repository ppa:formorer/icinga

### Debian ###

# wget -O - 2>/dev/null | apt-key add -

---- Jessie ----
# echo 'deb debmon-jessie main' > /etc/apt/sources.list.d/debmon.list
# echo 'deb jessie-backports main' >> /etc/apt/sources.list.d/debmon.list
---- Wheezy ----
# echo 'deb debmon-wheezy main' > /etc/apt/sources.list.d/debmon.list
# echo 'deb wheezy-backports main' >> /etc/apt/sources.list.d/debmon.list

Update the repository cache.

# apt-get update

Install Icinga 2 package.

# apt-get install -y icinga2

As part of the installation, Icinga 2 service should start automatically; if not, start the Icinga 2 service using the following command.

### For SysVinit systems ###

# service icinga2 start

### For Systemd systems ###

# systemctl start icinga2

Set Icinga 2 service to start automatically on system startup.

### For SysVinit systems ###

# update-rc.d icinga2 defaults

### For Systemd systems ####

# systemctl enable icinga2

Installing Nagios Plugins

Without the plugins, Icinga 2 does not know how to monitor the external services. So install Nagios plugins on top of Icinga 2.

# apt-get install -y nagios-plugins

Creating IDO MySQL Database

The DB IDO module for Icinga 2 takes care of exporting all the configuration and status information to the database; we need to have database server for this requirement. At present, MySQL and PostgreSQL are supported. Here, we will use MySQL as a database server.

If you already have a MySQL server installed, you can skip the below step.

# apt-get install -y mysql-server mysql-client

Now, install IDO modules for MySQL using the following command. You can find the icinga2-ido-mysql package in Icinga 2 repository.

# apt-get install -y icinga2-ido-mysql

During the installation IDO modules, the installer will prompt you regarding the module installation. Here is how you should answer them.

  1. Please select No for Enabling IDO Modules feature on Icinga 2
  2. Select No on Configuring IDO modules with Icinga 2 ( We will manually setup database for IDO modules)

Create a MySQL database for Icinga 2.

# mysql -u root -p

### Create a Database of IDO modules ###

mysql>  CREATE DATABASE icinga2;
mysql>  grant all privileges on icinga2.* to icinga2@localhost identified by 'icinga123';
mysql> quit

After creating the database, you shall import the Icinga 2 IDO schema using the following command.

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

Enabling the IDO MySQL Module

We would need to enable the ido-mysql in Icinga 2. Let’s first lists the available and enabled features in Icinga 2.

By default, Icinga 2 is enabled with below three features.

  1. Checker – for executing checks
  2. notification – for sending notifications
  3. mainlog – for writing the icinga2.log file

If ido-mysql is not enabled, please enable it.

$ icinga2   feature  enable ido-mysql

Also, enable the “command” feature which helps Icinga web interface and other Icinga add-ons to send commands to Icinga 2 via the external command pipe.

$ icinga2 feature enable command

Add web server’s user (www-data) to the icinga-cmd group to allow Icinga web interface to send commands to Icinga 2.

### Ubuntu ###

# usermod -a -G icingacmd www-data

### Debian ###

# usermod -a -G nagios www-data

Configure IDO DB MySQL

Once you enabled the IDO modules, Icinga 2 places the new configuration file at /etc/icinga2/features-enabled/ido-mysql.conf in which we need to update the database credentials manually.

# vi /etc/icinga2/features-enabled/ido-mysql.conf

Update the above file shown like below.

user = "icinga2",
password = "icinga123",
host = "localhost",
database = "icinga2"

Restart the Icinga 2 instance to have this enabled features take effect.

### For SysVinit systems ###

# service icinga2 restart

### For Systemd systems ###

# systemctl restart icinga2

That’s all for now. We will configure Icinga 2 web interface in our next tutorial.


You might also like
  • mispe

    Commando: usermod -a -G icingacmd www-data
    result: usermod: group ‘icingacmd’ does not exist

    • Raj

      Please add group using the following command.

      groupadd icingacmd

  • lotas

    When running the commad: mysql -u root -p icinga2 < /usr/share/icinga2-ido-mysql/schema/mysql.sql

    I have the following error:

    Error 1101 (42000) at line 24: BLOB, TEXT, GEOMETRY or JSON column 'comment_data' can't have a default value

  • lotas

    If I’m running the sql file from the database using “source” I have the following error in most of the tables.

Linux Monitoring Tool: Install Icinga2 on Ubuntu 16.04 / 14.04 , Debian, and Mint