Icinga2 is a free, open-source, and cross-platform monitoring tool written in PHP and C++. It can monitor network resources, notifies outages, large complex environments, generate performance data for reporting. Icinga is scalable and extensible.
Icinga capabilities include monitoring SMTP, POP3, HTTP, NNTP, ping, CPU load, disk usage, switches, routers, and more.
The Icinga stack consists of Icinga2 - which monitoring server and Icinga Web 2 - is the web interface to keep monitoring.
In this tutorial learn how to install Icinga2 on Ubuntu 20.04 LTS. We also configure the Icinga Web 2 interface.
Step 1: Install LAMP Stack
Icinga runs on a web server and is accessed from a browser. So the first step is to install the LAMP stack. LAMP is the acronym for Linux Apache MariaDB/MySQL and PHP. Apache is the webserver, MariaDB is the database server and PHP is the popular server-side scripting language.
Let's begin. First update the package lists:
$ sudo apt update
To install Apache web server, run the command:
$ sudo apt install apache2
Once Apache is installed, enable it to automatically start on boot time.
$ sudo systemctl enable apache2
Then Start Apache daemon.
$ sudo systemctl start apache2
To confirm that the web server is running, execute:
$ sudo systemctl status apache2
Moving on, we will install the MariaDB database server and client.
$ sudo apt install mariadb-server mariadb-client
Once the installation is complete, enable MariaDB to start on boot.
$ sudo systemctl enable mariadb
Then start the MariaDB daemon.
$ sudo systemctl start mariadb
Once again, verify the status of MariaDB
$ sudo systemctl status mariadb
To harden the database server run the script
$ sudo mysql_secure_installation
Be sure to secure the database server with a root password.
And answer 'Yes' for the remaining prompts to secure the database server.
Moving on, we will install PHP which is the remaining component of the LAMP stack. But first, install the dependencies shown.
$ sudo apt install software-properties-common
Then add the OndeJ repository which provides the latest version of PHP, which currently is PHP 8.0. Icinga requires PHP 7.3 and later versions so we are well within the required version range.
$ sudo add-apt-repository ppa:ondrej/php
Once the repository is added, install PHP and the required dependencies for installation of Icinga
$ sudo apt install php php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip php-cli php-mysql php8.0-common php8.0-opcache php-gmp php-imagick
Then verify the version of PHP installed.
$ php -v
A few modifications are required. Edit the php.ini file.
$ sudo vim /etc/php/8.0/apache2/php.ini
Be sure to set the date.timezone parameter and set the cgi.fix_pathinfo parameter to 0.
date.timezone = Africa/Kolkata cgi.fix_pathinfo=0
Save the changes and exit.
Step 2: Add the Icinga2 repository
The next step is to install Icinga2 on Ubuntu. However, since Icinga's repository is not hosted on the Ubuntu repository, we need to manually add the repository locally.
First, add Icinga's GPG key
$ curl https://packages.icinga.com/icinga.key | apt-key add -
Next, create a repository file for Icinga in the /etc/apt/sources.list.d directory.
$ sudo vim /etc/apt/sources.list.d/icinga-focal.list
Then add the following lines to define where Ubuntu will download Icinga from.
deb http://packages.icinga.com/ubuntu icinga-focal main
deb-src http://packages.icinga.com/ubuntu icinga-focal main
Save and exit the configuration file.
Step 3: Install Icinga2
First, update the package lists and repositories first.
$ sudo apt update
Then install Icinga2 and monitoring plugins.
$ sudo apt install icinga2 monitoring-plugins
Once installed, enable the Icinga monitoring tool.
$ sudo systemctl enable icinga2
Then start the service.
$ sudo systemctl start icinga2
Then check the running status of Icinga.
$ sudo systemctl status icinga2
Icinga is running as expected and that's a good sign that we are headed in the right direction.
Step 4: Install the Icinga2 IDO MySQL module
The Icinga Data Output (IDO) feature exports all the configuration and status information into a database. The IDO database is used as a data backend by Icinga Web 2.
To install the Icinga IDO database module, run the command:
$ sudo apt install icinga2-ido-mysql
The installation will get underway and along the way, you get this pop-up prompting you to enable Icinga 2's ido-mysql feature. Select 'Yes' option and press ENTER.
The icinga2-ido-mysql module must have a database installed and configured so that it can be used. We are going to configure the database manually in the MariaDB database server, so when prompted whether to create it automatically, select 'No' and press ENTER.
The next step is to manually create the database for the icinga2-ido-mysql module.
Login to MariaDB shell.
$ sudo mysql -u root -p
Run the commands provided to create the database, database user and grant all privileges to the user.
> CREATE DATABASE icinga2db; > GRANT ALL ON icinga2db.* TO 'icinga2user'@'localhost' IDENTIFIED BY 'P@ssword'; > FLUSH PRIVILEGES; > EXIT;
Once the database is in place, import the Icinga2 IDO schema using the command shown. When prompted, type the root password and hit ENTER.
Step 5: Enable the IDO MySQL module
The IDO package comes with its configuration file called ido-mysql.conf. We need to access this file and modify the database connection details.
So, access the configuration file.
$ sudo vim /etc/icinga2/features-available/ido-mysql.conf
Edit the database details for the user, password, host, and database with what you specified in the previous step and save the changes
Thereafter, enable the ido-mysql module.
$ sudo icinga2 feature enable ido-mysql
To effect all the changes we have made, restart the Icinga2 service.
$ sudo systemctl restart icinga2
Step 6: Install and setup Icinga Web 2
The next step is to install Icinga Web 2 package. This is a powerful and extensible PHP framework for applications that provides a neat and intuitive IU for Icinga.
To install Icinga Web 2 alongside with Icinga2 client and PHP module run the command:
$ sudo apt install icingaweb2 icingacli libapache2-mod-php
Once installed, create a database for Icinga Web 2 as follows.
$ sudo mysql -u root -p
Define the database and database user and assign privileges and save the changes.
> CREATE DATABASE icingaweb2; > GRANT ALL ON icingaweb2.* TO 'icingaweb2user'@'localhost' IDENTIFIED BY 'P@ssword'; > FLUSH PRIVILEGES; > EXIT;
The next step involves setting up Icinga2 using the Icinga2 Web wizard installer. This requires a token, and therefore generates the token using the Icinga client.
$ sudo icingacli setup token create
Copy and paste this token somewhere.
If you clear the screen or forget the token, don't worry. You can display it at some other point in time, by running:
$ sudo icingacli setup token show
Step 7: Set up Icinga Web 2 on the browser
To access the Icinga2 Web installer browse the following address:
You will get the welcome page shown. Paste the token you created and press 'Next'.
The next page presents all the modules that can be activated. By default 'Monitoring' is selected which will be enough for now. Feel free to activate others.
Once done, click on the 'Next' button.
The next page shows all the PHP modules that have been enabled. As we installed the required modules, you shouldn't get an error or warning.
Simply scroll down and click the Next button.
For authentication type, choose 'Database' and click 'Next'.
Next, enter the database details that you created for Icinga in Step 4.
At the bottom click on 'Validate configuration' to check if the database details provided are correct.
if everything went according to plan, you will get a notification that the configuration has been successfully validated.
In the next step, just click next to accept the default selection of Icingaweb2 as the authentication backend type.
Next, create the Admin user that you will use to login to Icinga web GUI.
In the next step, just hit ENTER to accept the default Application configuration details.
At this point, Icinga2 has been successfully configured. Review all the settings made. If all looks good, scroll down and hit the Next button.
The next step requires you to configure the monitoring module. This is the core module that provides you with powerful filtering capabilities and helps you to keep track of events. So, click the Next button.
In the 'Monitoring IDO Resource' step, fill out the database details for Icinga2 Web created in Step 6.
Scroll all the way down and click 'Validate configuration' to confirm if the settings are Ok.
If all the settings are okay, you should get confirmation that the configuration was validated successfully.
For Command Transport select Local Command File and click Next.
For Monitoring Security simply press Next to accept the defaults.
Finally review all the module configuration settings.
If all looks good. Click on the Finish button, else head back and edit some of the settings.
You will get a confirmation that Icinga Web 2 has successfully been set up. To log in click on the link Login to Icinga Web 2 button.
This brings you to the login screen. Type the Icinga login credentials and press the Login button.
Once logged in, you will get the dashboard provided.
In this tutorial, we learned how to install Icinga2 and Icinga Web 2 on Ubuntu 20.04. Thanks for reading, please lets us know your suggestions in the below comment section.