Bobcares

How to install and configure Icinga2 monitoring tool on Ubuntu 20.04?

by | Sep 25, 2020

Icinga monitoring system checks the availability of the network resources and notifies users of outages. Install of icinga2 on Ubuntu mainly involves two stages of tasks.

As a part of our Server Management Services, we help our Customers with software installations regularly.

Let us today discuss the steps to install and configure the Icinga2 monitoring tool on Ubuntu 20.04.

Install and Configure Icinga 2 on Ubuntu

Sufficient monitoring of core resources on a server relieves webmasters and website owners from panic and fear of unnoticed critical service changes.

Icinga, a commonly used monitoring tool checks the availability of the network resources, notifies users of outages, and generates performance data for reporting.

The install of icinga2 on Ubuntu mainly includes two stages. The initial stage is to install icinga2 and the next stage is to set up the Icinga Web 2 interface.

Let us now discuss the steps for install in detail.

Update and install essential applications

The first step in the installation process is to make sure that the packages in the server are up to date. It can be done with the command below:

$ sudo apt update && sudo apt upgrade

Further, we also require to install some essential application with the command below:

$ sudo apt install -y vim apt-transport-https wget gnupg

 

Add Icinga Package Repository

We will need to add the Icinga repository to our server package management configuration as shown below:

$ wget -O - https://packages.icinga.com/icinga.key | sudo apt-key add -
. /etc/os-release; if [ ! -z ${UBUNTU_CODENAME+x} ]; then DIST="${UBUNTU_CODENAME}"; else DIST="$(lsb_release -c| awk '{print $2}')"; fi;
echo "deb https://packages.icinga.com/ubuntu icinga-${DIST} main" | sudo tee /etc/apt/sources.list.d/${DIST}-icinga.list
echo "deb-src https://packages.icinga.com/ubuntu icinga-${DIST} main" | sudo tee -a /etc/apt/sources.list.d/${DIST}-icinga.list

Then update the server to get packages from the newly added repository.

$ sudo apt update

 

Install Icinga2 on Ubuntu

Now that we have the official Icinga repository, we can install Icinga 2 by using the apt package manager to get the icinga2 package as below.

$ sudo apt install icinga2 -y

 

Setting up Check Plugins

Icinga 2 requires plugins to check external services. The Monitoring Plugins Project provides an extensive set of plugins that can be used with Icinga 2. It helps to check whether services are working properly. Use the command below to install it:

$ sudo apt install monitoring-plugins -y

Now, start and enable icinga2. Further, also verify the status of the service.

$ sudo systemctl enable --now icinga2

$ systemctl status icinga2

 

Installing MySQL/MariaDB and Configuring DB IDO MySQL

The Database Icinga Data Output (DB IDO) feature for Icinga 2 takes care of exporting all configuration and status information into a database. Let us install MariaDB and the Database Icinga Data Output.

To install MariaDB 10.5 on Ubuntu 20.04 LTS, execute the commands given below:

$ sudo apt update && sudo apt upgrade
$ sudo apt -y install software-properties-common
$ sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
$ sudo add-apt-repository 'deb [arch=amd64] http://mariadb.mirror.globo.tech/repo/10.5/ubuntu focal main'
$ sudo apt update
$ sudo apt install mariadb-server mariadb-client
$ sudo mysql_secure_installation
$ sudo systemctl status mysql

After that, install DB IDO with the command below:

$ sudo apt install icinga2-ido-mysql -y

When it asks to install and configure Database, choose no option as we have already performed it.

Next, create a database and user for Icinga2.

$ mysql -u root -p

MariaDB [(none)]> CREATE DATABASE icinga;
MariaDB [(none)]> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY 'icinga';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> quit

After creating the database we can import the Icinga 2 IDO schema using the command below:

$ mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/mysql.sql
Enter password: <Enter-your-root-password>

 

Enable the IDO MySQL module

The package provides a new configuration file that is installed in /etc/icinga2/features-available/ido-mysql.conf. Update the database credentials in this file.

$ sudo vim /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 = "icinga",
password = "icinga",
host = "localhost",
database = "icinga"
}

Next, enable the ido-mysql feature configuration file using icinga2 feature enable as follows:

$ sudo icinga2 feature enable ido-mysql

Make sure to restart Icinga 2 for these changes to take effect

$ sudo systemctl restart icinga2

 

Setting Up Icinga 2 REST API

Icinga Web 2 and other web interfaces require the REST API to send actions (reschedule check, etc.) and query object details. We can enable the api feature using the icinga2 CLI command like this:

$ sudo icinga2 api setup

 

This command will also set up certificates and a new API user root with an auto-generated password in the /etc/icinga2/conf.d/api-users.conf config file.

Edit the /etc/icinga2/conf.d/api-users.conf file and add a new ApiUser object below the auto-generated one. Also, specify the permissions attribute with minimal permissions required by Icinga Web 2.

$ sudo vim /etc/icinga2/conf.d/api-users.conf

object ApiUser "icingaweb2" {
password = "*********"
permissions = [ "status/query", "actions/*", "objects/modify/*", "objects/query/*" ]
}

This API will be listening on port 5665 by default. Further, restart Icinga 2 to activate the new configuration made.

$ sudo systemctl restart icinga2

 

Setting up Icinga Web 2

Icinga 2 can be used with Icinga Web 2 and a variety of modules to take improve monitoring. Let us now look at the steps to set up Icinga Web 2.

Add Package Repository

We can install Icinga Web 2 using the official package repository. To install Icinga Web 2 on the same server as Icinga 2, we don’t need to add the repositories once again.

On the other hand, to install Icinga Web 2 on a separate server, we will have to do update packages and add the repository as we did earlier.

Install Icinga Web 2

We shall use the apt package manager to retrieve and install the icingaweb2 package.

$ sudo apt install icingaweb2 libapache2-mod-php icingacli -y

Prepare Web Setup

To prepare for web setup, we will have to manually create a database and a database user. If we are on a separate server, we will have to install MariaDB/MySQL for this part.

However, on the same server, skip the link and proceed to add the database user.

$ mysql -u root -p

MariaDB [mysql]> CREATE DATABASE icingaweb2;
MariaDB [mysql]> GRANT ALL ON icingaweb2.* TO icingaweb2@localhost IDENTIFIED BY 'StrongPassword';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> quit

Now, we can set up Icinga Web 2 with the Icinga Web 2 setup wizard. This displays when we visit Icinga Web 2 in the browser for the first time.

While using the web setup we need to authenticate using a token. In order to generate a token we shall use the icingacli tool:

$ sudo icingacli setup token create

We can later display the token using the icingacli:

$ sudo icingacli setup token show

Further, allow port 80 or 443 (if you are using https) in the firewall.

$ sudo ufw allow http

 

Starting Web Setup

The link  http://[domain-name-or-ip-address]/icingaweb2/setup will open the Setup wizard. On the first page, we will be asked to enter the token we created earlier.

Modules

Page two prompts us to activate the other modules that the Icinga team put together. Simply activate them if required and then click “Next” for the next step.

PHP Modules

The page that follows shows us the PHP modules that are available and the ones that are missing. Click “Next”.

Configure Authentication Type

install icinga2 on ubuntu

Now we need to choose an Authentication type. If we have an LDAP implementation or would like to use Database, choose the one that suit s the need from the drop-down list. Hit “Next” once done.

Configure Database|LDAP

Depending on our previous selection, it asks to fill the details Icinga Web 2 needs to authenticate users. Enter the DB details we used fr the web setup. Then click “Validate Configuration” to cross-check whether the details are correct. Click on “Next” when done.

Authentication Backend

This page will ask for a name for the backend.

Add an administrative user

Next, we shall add an Administrative user that we will use to log into Icinga web 2 once the setup is done. It is through this account that we shall be able to create others as well.

Application Configuration

install icinga2 on ubuntu

Here, we can adjust all application and logging related configuration options.

Review of configurations done

At this stage, we need to confirm our settings before setting it up. Once everything is ok, hit “Next“.

Configuring monitoring module

The monitoring module offers various status and reporting views. This allows us to keep track of the most important events in the monitoring environment. Click “Next” to start configuring the monitoring module.

Configure Monitoring Backend

This will guide Icinga 2 on how it should retrieve monitoring information.

Monitoring IDO Resource

Fill out the connection details below to access the IDO database we configured earlier. Validate the settings and then click “Next“.

After proper validation, we should see a success message. Click “Next” to move forward.

Command Transport

Here we need to enter the details we used during the API setup. Once done keying in the credentials, click on “Validate” to check if everything was set correctly.

Monitoring Security

Fill out these settings to protect the monitoring environment against attacks.

Final Monitoring module Review

We can review the changes supposed to be made before finishing the setup in this step. If required, we can navigate back to make any corrections. Otherwise, click on “Finish” and we will receive a message that “Icinga Web 2 has been successfully set up“.

Click on “Login to Icinga Web 2” and it will take us to the “Login page”. Enter the administrative user we created earlier and we should be logged in.

[Need any further assistance to install icinga2 on ubuntu? – We’re available 24*7]

 

Conclusion

In short, sufficient monitoring of core resources on a server relieves webmasters and website owners from panic and fear of unnoticed critical service changes.  Today, we saw how our Support Engineers install icinga2 on Ubuntu.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.