How to Install Icinga 2 and Icinga Web 2 on Ubuntu 18.04 LTS

3
6373

Icinga 2 is an open source monitoring system which checks the availability of your network resources (CPU load, uptime, free disk space, memory consumption), notifies users of outages and generates performance data for reporting. It is scalable and therefore it can be used to monitor large, complex environments across multiple locations.

It has a lightweight and extensible web interface called Icinga Web 2 that enables you to visualize and keep an eye on your environment.

In this tutorial, we are going to learn how to install Icinga 2 and Icinga Web 2 on Ubuntu 18.04 LTS. Step through the following procedures in order to make this happen.

Installing Icinga Package Repositories

Before you can install Icinga 2, you need to add the Icinga 2 repository to your package management configuration.

# apt-get -y install apt-transport-https
# wget -O - https://packages.icinga.com/icinga.key | apt-key add -
# echo "deb http://packages.icinga.com/ubuntu icinga-bionic main" > /etc/apt/sources.list.d/icinga2.list
# echo "deb-src http://packages.icinga.com/ubuntu icinga-bionic main" >> /etc/apt/sources.list.d/icinga2.list

Once that is done, resynchronize the package index files from their sources and upgrade your system.

# apt-get update
# apt-get upgrade

Install Icinga 2

Now that the repositories are ready, run the command below to install Icinga 2.

# apt-get install icinga2 -y

The basic installation of icinga 2 enables the following features;

  • checker for executing checks
  • mainlog for writing the icinga2.log file
  • notification for sending notifications

You can verify that these features are enabled by running the command:

# icinga2 feature list | grep -i enabled
Enabled features: checker mainlog notification

Set up Icinga 2 Check Plugins

In order for Icinga 2 to monitor system metrics such as load averages, processes, or disk space usage or any other system remote checks, it requires the check plugins. Run the command below to install the check plugins.

# apt-get install monitoring-plugins -y

Run Icinga 2

Now that you have installed icinga 2 and its check plugins, set icinga2 service to start on system reboot. Note that by default, icinga2 starts automatically after installation.

You can check the status using the command below;

# systemctl status icinga2

If for some reason it is not running, start by running the command below;

# systemctl start icinga2

Enable it to start on system reboot

# systemctl enable icinga2

Setting up Icinga Web 2

Icinga 2 can be used with Icinga Web 2. Icinga Web 2 is a powerful PHP framework for web applications that comes in a clean and reduced design. It’s fast, responsive, accessible and easily extensible with modules.

In order to install and setup Icinga Web 2, ensure that the following prerequisites are met.

  • IDO (Icinga Data Output) database backend (MySQL or PostgreSQL)
  • A web server, e.g. Apache or Nginx
  • PHP version >= 5.6.0
  • PHP modules must be installed: cURL, gettext, intl, mbstring, OpenSSL and xml
  • Default time zone configured for PHP in the php.ini file
  • MySQL or PostgreSQL PHP libraries

Configure DB IDO MySQL

The DB IDO module for Icinga 2 takes care of exporting all the configuration and status information to the database. The supported database backends include MySQL/MariaDB and PostgreSQL.

Installing MySQL database server

In this tutorial, we are going to use MariaDB. To install MariaDB, run the command below.

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

Once the installation is done, run the following command to improve the security of your MySQL/MariaDB installation by maybe setting root password and removing test databases, anonymous-user accounts, disallowing remote root login.

# mysql_secure_installation

Installing the IDO modules for MySQL

Since we have enabled Icinga 2 repositories above, run the command below to install IDO modules.

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

During installation, the database configuration wizard will prompt you to set some configurations.

  • The first prompt asks you whether to enable Icinga 2’s ido-mysql feature. Select Yes to enable this feature.
Enabling Icinga 2’s ido-mysql feature
  • The second prompt asks you whether to Configure database for icinga2-ido-mysql with dbconfig-common. Select Yes to accept this.
Configuring database for icinga2-mysql with dbconfig-common
  • The third prompt asks you to set Icinga database password. Set a secured password and save it for later use.

Enable the IDO MySQL Feature

To enable ido-mysql feature in the backend, run the command below. ou can also enable a command feature that enables you to manual health checks from the Icinga 2 Web Interface.

# icinga2 feature enable ido-mysql command

The ido-mysql configuration file is /etc/icinga2/features-available/ido-mysql.conf. You can view the contents of this file by running the command below;

# less /etc/icinga2/features-available/ido-mysql.conf
/**
 * The db_ido_mysql library implements IDO functionality
 * for MySQL.
 */

library "db_ido_mysql"

object IdoMysqlConnection "ido-mysql" {
  user = "icinga2",
  password = "SECUREDPASS",
  host = "localhost",
  database = "icinga2"
}

Restart Icinga 2 for these changes to take effect.

# systemctl restart icinga2

Install Icinga Web 2

Run the command below to install Icinga 2 and its command utility, icingacli. Note that Icinga will install and set up Apache web server by default as well as PHP all the PHP modules required for Icinga Web 2 to run.

# apt-get install icingaweb2 icingacli -y

Once the installation is done, you need set a timezone to be set for the PHP environment, so edit the PHP config file, /etc/php/7.2/apache2/php.ini and set timezone as follows

# vim /etc/php/7.2/apache2/php.ini
...
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =
date.timezone = Africa/Nairobi
...

Restart the Apache service to effect the changes.

# systemctl restart apache2

3 COMMENTS

  1. Great tutorial, thank you! I also tried another tutorial that didn’t work.

    It’d be great if you could create tutorials for graphite and director as well! 😀

LEAVE A REPLY

Please enter your comment!
Please enter your name here