Install Icinga 2 and Icinga Web 2 on Ubuntu 20.04

0
1470

In this tutorial, we are going to learn how to install Icinga 2 and Icinga Web 2 on Ubuntu 20.04. Icinga 2 is a scalable and extensible opensource monitoring solution that checks the availability of various network resources including host metrics such as system uptime, load, memory, disk free space, running processes, network services such as HTTP, SMTP, SNMP, SSH, etc. Icinga supports notifications and can be configured to notify users of system/service outages and generates performance data for reporting.

Install Icinga 2 and Icinga Web 2 on Ubuntu 20.04

Run system update

Run the command below to update your system packages.

apt update
apt upgrade

Install Icinga 2 on Ubuntu 20.04

Installing Icinga 2 from the official package repositories is a preferred way of installation. Fortunately, Ubuntu 20.04 repos provides Icinga 2 packages. However, the available package may not be up-to-date hence be sure to check official Icinga 2 repositories if Ubuntu 20.04 repos have been availed.

Thus, to install Icinga 2 from Ubuntu 20.04 repos

apt install icinga2

Enable Icinga 2 Main Features

During the installation, there are three main features of Icinga 2 that are enabled. These are:

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

For the enablement to take effect, Icinga 2 service has to be restarted (Icinga 2 is started and enabled during installation);

systemctl restart icinga2

To check the status of Icinga 2;

systemctl status icinga2
● icinga2.service - Icinga host/service/network monitoring system
     Loaded: loaded (/lib/systemd/system/icinga2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2020-05-03 07:22:32 UTC; 25s ago
       Docs: https://icinga.com/docs/icinga2/latest/
    Process: 3118 ExecStartPre=/usr/lib/icinga2/prepare-dirs /usr/lib/icinga2/icinga2 (code=exited, status=0/SUCCESS)
   Main PID: 3138 (icinga2)
      Tasks: 15 (limit: 2283)
     Memory: 13.2M
     CGroup: /system.slice/icinga2.service
             ├─3138 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon -e
             ├─3155 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon -e
             ├─3156 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon -e
             ├─3183 /usr/lib/nagios/plugins/check_ping -6 -H ::1 -c 200,15% -w 100,5%
             └─3184 /bin/ping -6 -n -U -w 10 -c 5 ::1

Install Icinga 2 Monitoring Plugins on Ubuntu 20.04

Monitoring of external services can only be possible through the use of monitoring plugins. Therefore, run the command below to install Icinga 2 monitoring plugins.

apt install monitoring-plugins

Install and Configure Icinga 2 Backend Database

Icinga 2 Database Icinga Data Output (DB IDO) exports all configuration and status information into a database which can either by MySQL/MariaDB or PostgreSQL. In this tutorial, we are using MySQL 8.

Install MySQL Database

apt install mysql-server

Once the installation is done, run the MySQL initial security script to remove test databases, anonymous users, disallow remote root login…

mysql_secure_installation

Install Icinga Data Output modules for MySQL.

apt install icinga2-ido-mysql

When prompted, enable Icinga 2 to use MySQL as the backend database.

If not enabled, this feature can be enabled later by running the command;

icinga2 feature enable ido-mysql

To list enabled features, run the command;

icinga2 feature list

Next, choose whether you want to use the automated setup wizard to configure icinga2-ido-mysql. We chose to go the manual way by selecting No in this tutorial.

Create MySQL Database for Icinga 2

To create the Icinga 2 database, login as root user;

mysql -u root -p

Then create the database. Note, names used here are not standard, use any name you like;

create database icinga2db;

Create the database user and grant all the privileges on Icinga 2 database created above.

create user [email protected] identified with mysql_native_password by '[email protected]';
grant all on icinga2db.* to [email protected];

Reload privileges tables and exit the database.

flush privileges;
quit

Import the Icinga 2 IDO schema

Next, import Icinga 2 IDO schema into Icinga 2 database created above. Replace the database name accordingly.

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

Configure Icinga 2 Database Connection Settings

Open the Icinga 2 MySQL IDO configuration file to define the Icinga 2 database connection settings;

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 = "icingaadmin",
  password = "[email protected]",
  host = "localhost",
  database = "icinga2db"
}

Save and exit the file and restart Icinga 2 daemon

systemctl restart icinga2

Install Icinga Web 2 on Ubuntu 20.04

Icinga Web 2 is a powerful PHP framework that provides web management interface for Icinga 2. Install PHP and required modules.

Note, PHP 7.4 is the default version on Ubuntu 20.04. Icinga 2 web is not compatible with PHP 7.4 yet. As such, we choose to install PHP 7.2 from ondrej PPA repos.

Install the PPA repos;

apt install software-properties-common
add-apt-repository ppa:ondrej/php --yes
apt update

To install these packages;

apt install apache2 php7.2 php7.2-{cli,curl,gd,ldap,json,intl,imagick,curl,gettext,intl,mbstring,xml,mysql} openssl

Next, install Icinga 2 web and CLI management packages.

apt install icingaweb2 icingacli

Create Icinga Web 2 Database

Again, login to MySQL database and create a database and database user for Icinga 2 web.

To create the Icinga 2 database, login as root user;

mysql -u root -p
create database icinga2webdb;
create user [email protected] identified with mysql_native_password by '[email protected]';
grant all on icinga2webdb.* to [email protected];
flush privileges;
quit

Prepare Icinga 2 Web Setup

Generate Icinga Web 2 authentication tokens;

icingacli setup token create

This will generate such a token as:

The newly generated setup token is: 45cc9d7735d4e833

You can as well display the token using the command;

icingacli setup token show

Ensure that a icingaweb2 system group exists and that the web server user, www-data, is a member of the group.

getent group icingaweb2
icingaweb2:x:120:www-data
groups www-data
www-data : www-data icingaweb2

Restart Apache web server.

systemctl restart apache2

Finalize Icinga 2 Web Setup on Browser

To finalize the setup on browser, access Icinga 2 web using the address http://<icinga-server-IP-or-hostname>/icingaweb2/setup.

Enter your authentication token generated and click next to proceed.

Install Icinga 2 and Icinga Web 2 on Ubuntu 20.04

Choose Icinga 2 modules to enable. In this tutorial, we go with the defaults with monitoring modules only enabled.

On the next page, the setup wizards verifies if all the required PHP modules are in place.

Install Icinga 2 and Icinga Web 2 on Ubuntu 20.04

If all is well, click Next to proceed, otherwise install any missing PHP extensions and proceed with setup.

Choose the mode of authentication. We use database authentication in this demo.

Install Icinga 2 and Icinga Web 2 on Ubuntu 20.04

Configure Icinga 2 Web database connection settings. Click Validate Configuration to test connection to database.

Choose authentication backend database.

Install Icinga 2 and Icinga Web 2 on Ubuntu 20.04

Create Icinga Web 2 administrative user.

Choose your application configuration settings.

Install Icinga 2 and Icinga Web 2 on Ubuntu 20.04

Icinga Web 2 application configuration summary.

Click Next,Next to proceed. Configure Icinga Web 2 monitoring module.

Configure Icinga 2 Database connection settings.

Install Icinga 2 and Icinga Web 2 on Ubuntu 20.04

If upon validating the configuration you get the error, There is currently no icinga instance writing to the IDO. Make sure that a icinga instance is configured and able to write to the IDO., it simply means ido-mysql feature is not enabled. Enable it and restart Icinga 2.

Configure Icinga Transport commands. Local command transport type is used in this demo. Read more on Icinga web 2 command transport.

Configure your protected Custom Variables and click next then finish Icinga web 2 setup.

Icinga Web 2 is now setup. Click Login to Icinga Web 2 and login using the admin credentials created during the installation.

Install Icinga 2 and Icinga Web 2 on Ubuntu 20.04

Icinga 2 monitoring dashboard.

Install Icinga 2 and Icinga Web 2 on Ubuntu 20.04

Magnificent!! That is just how simple it is to install Icinga 2 and Icinga Web 2 on Ubuntu 20.04.

You can now add your hosts for monitoring.

How to Monitor Remote Linux Hosts and Services with Icinga 2

Read more on Icinga 2 documentation page.

Related Tutorials

Install and Setup Nagios Core on Ubuntu 20.04

Install Icinga 2 on Debian 10 Buster

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

Install Nagios Core on Debian 10 Buster

Install Zabbix 4.x from Sources on Debian 10 Buster

LEAVE A REPLY

Please enter your comment!
Please enter your name here