How to Install Icinga 2 on Ubuntu 16.04, Debian 9 & Mint – A System and Network Monitoring Tool

4

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 9, Mint.

Article Series:

1: Install Icinga2 on Ubuntu 16.04 / Debian 9, and Mint

2: Setup Icinga Web 2 on Ubuntu 16.04 / Debian 9 / Mint

3: Add Remote Linux Host into Icinga 2 Server

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

Prerequisites

Icinga provides you the official repository for their packages. You can either use Icinga PPA or Icinga repository. Here, we will use the Icinga repository,

First, switch to the root user.

$ su -

OR

$ sudo su -

Install the below package for https support.

apt-get update
apt-get install -y wget apt-transport-https

Add the Icinga key to the system.

wget -O - https://packages.icinga.com/icinga.key | apt-key add -

Now, add the Icinga repository using the following command.

cat <<EOF > /etc/apt/sources.list.d/icinga2.list
deb http://packages.icinga.com/$(lsb_release -si | tr '[:upper:]' '[:lower:]') icinga-$(lsb_release -cs) main
deb-src http://packages.icinga.com/$(lsb_release -si | tr '[:upper:]' '[:lower:]') icinga-$(lsb_release -cs) main
EOF

Install Icinga 2

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, then 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 the system startup.

### For SysVinit systems ###

update-rc.d icinga2 defaults

### For Systemd systems ####

systemctl enable icinga2

Install 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

Create IDO MySQL Database

The DB IDO module for Icinga 2 takes care of exporting all the configuration and status information to the database. At present, MySQL, Oracle, 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

In Ubuntu, during the installation, the installer will prompt you for setting the MySQL root password.

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 of 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)

Login to MySQL.

mysql -u root -p

Create a database for Icinga 2.

CREATE DATABASE icinga2;
grant all privileges on icinga2.* to icinga2@localhost identified by 'icinga123';
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

Enable 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

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. In our next tutorial, we will configure Icinga 2 web interface to monitor the servers.

Further Reading

You might also like

How to Install Icinga 2 on Ubuntu 16.04, Debian 9 & Mint – A System and Network Monitoring Tool

4