Icinga2 is an open-source network monitoring program written in PHP and C . It is one of the most popular tools for system administrators to monitor network resources, report outages and generate performance data for reports. With Icinga2, you can monitor various protocols and resources such as SMTP, POP3, HTTP, NNTP, ping, CPU load, disk usage, switches, routers and more. It consists of two stacks: Icinga2 and Icinga Web 2. Icinga2 is used as the monitoring server, while Icinga Web 2 is the web interface for further monitoring.

This article will show you how to install the Icinga2 monitoring server on Ubuntu 22.04.

Prerequisites

  • A server running Ubuntu 22.04.
  • A root password is set up on the server.

Install Apache, MariaDB and PHP

First you need to install the Apache web server, MariaDB, PHP and other required extensions on your server. You can install them all with the following command:

apt-get install apache2 mariadb-server

At the time of writing this tutorial, Icinga2 supports PHP 7.4, so you will need to install PHP and other extensions on your server. First, install all required dependencies with the following command:

apt install software-properties-common ca-certificates lsb-release apt-transport-https

Next, add the PHP repository with the following command:

add-apt-repository ppa:ondrej/php

Next, install PHP and the other extensions with the following command:

apt install php7.4 libapache2-mod-php7.4 php7.4-curl php7.4-gd php7.4-mbstring php7.4-xml php7.4-xmlrpc php7.4-soap php7.4-intl php7.4-zip php7.4-cli php7.4-mysql php7.4-common php7.4-opcache php7.4-pgsql php7.4-gmp php7.4-imagick -y

Once all packages are installed, edit the php.ini file and change some settings:

nano /etc/php/7.4/apache2/php.ini

Change the following lines:

memory_limit = 256M 
post_max_size = 64M
upload_max_filesize = 100M	
max_execution_time = 300
default_charset = "UTF-8"
date.timezone = "UTC"
cgi.fix_pathinfo=0

Save and close the file and restart the Apache service to apply the changes:

systemctl restart apache2

Secure MariaDB installation

Next, you need to set a MariaDB root password and secure the installation. You can do this by running the following script:

mysql_secure_installation

Answer all questions as shown below:

Enter current password for root (enter for none):
OK, successfully used password, moving on...
Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Install Icinga2

By default, the Icinga2 package is included in the default repository of Ubuntu 22.04. You can install it with the following command:

apt-get install icinga2 monitoring-plugins -y

Once all packages are installed, start Icinga2 and make sure it starts when the system reboots:

systemctl start icinga2
systemctl enable icinga2

To check the status of Icinga2, run the following command:

systemctl status icinga2

Sample output:

? icinga2.service - Icinga host/service/network monitoring system
     Loaded: loaded (/lib/systemd/system/icinga2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-09-18 08:25:17 UTC; 12s ago
       Docs: https://icinga.com/docs/icinga2/latest/
    Process: 86519 ExecStartPre=/usr/lib/icinga2/prepare-dirs /usr/lib/icinga2/icinga2 (code=exited, status=0/SUCCESS)
   Main PID: 86526 (icinga2)
     Status: "Startup finished."
      Tasks: 17 (limit: 4579)
     Memory: 12.6M
        CPU: 205ms
     CGroup: /system.slice/icinga2.service
             ??86526 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e ""
             ??86546 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e ""
             ??86551 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e ""

Sep 18 08:25:17 Ubuntu2204 icinga2[86546]: [2022-09-18 08:25:17  0000] information/ConfigItem: Instantiated 1 NotificationComponent.
Sep 18 08:25:17 Ubuntu2204 icinga2[86546]: [2022-09-18 08:25:17  0000] information/ConfigItem: Instantiated 1 UserGroup.
Sep 18 08:25:17 Ubuntu2204 icinga2[86546]: [2022-09-18 08:25:17  0000] information/ConfigItem: Instantiated 1 User.
Sep 18 08:25:17 Ubuntu2204 icinga2[86546]: [2022-09-18 08:25:17  0000] information/ConfigItem: Instantiated 3 TimePeriods.
Sep 18 08:25:17 Ubuntu2204 icinga2[86546]: [2022-09-18 08:25:17  0000] information/ConfigItem: Instantiated 3 ServiceGroups.
Sep 18 08:25:17 Ubuntu2204 icinga2[86546]: [2022-09-18 08:25:17  0000] information/ConfigItem: Instantiated 1 ScheduledDowntime.
Sep 18 08:25:17 Ubuntu2204 icinga2[86546]: [2022-09-18 08:25:17  0000] information/ConfigItem: Instantiated 12 Services.
Sep 18 08:25:17 Ubuntu2204 icinga2[86546]: [2022-09-18 08:25:17  0000] information/ScriptGlobal: Dumping variables to file '/var/cac>
Sep 18 08:25:17 Ubuntu2204 icinga2[86526]: [2022-09-18 08:25:17  0000] information/cli: Closing console log.
Sep 18 08:25:17 Ubuntu2204 systemd[1]: Started Icinga host/service/network monitoring system.

Next, you need to install the MySQL plugin for Icinga2. You can install it with the following command:

apt-get install icinga2-ido-mysql -y

During the installation, you will be asked if you want to enable the ido-mysql feature of Icinga 2:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Select Yes and press Enter. You will be asked if you want to create a database for Icinga2.

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Select Yes and press Enter . You will be prompted to set the password for the Icinga2 application:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Enter your password and press Enter to complete the installation.

This will create a database and a user named icinga2 and set a password.

Note: Please memorize the icinga2 database, user and password. You will need them during the web-based installation.

Next, activate the ido-mysql module with the following command:

icinga2 feature enable ido-mysql

Finally, restart the Icinga2 service to apply the changes:

systemctl restart icinga2

Installing and configuring Icinga Web 2

Icinga Web 2 provides a web interface to monitor Icinga2. You can install it with the following command:

apt-get install icingaweb2 icingacli -y

Once the installation is complete, you will need to create a database and user for Icinga Web 2.

First, log in to MariaDB with the following command:

mysql -u root -p

Once you are logged in, create a database and a user with the following command:

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

Next, delete the permissions and exit MariaDB with the following command:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Next, generate a secret token with the following command:

icingacli setup token create

You should get the following output:

The newly generated setup token is: 979eddaaa6ab6b89

Access to the Icinga2 web interface

Now open your web browser and call up the Icinga2 web installation wizard at the URL http://your-server-ip/icingaweb2/setup. You should see the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Enter your secret token and click the Next button. You should see the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Select Monitoring and click the Next button. You should see the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Make sure all PHP extensions are installed, then click the Next button. You should see the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Select your authentication type and click the Next button. You should see the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Enter your credentials for the Icinga2 web database and click the Next button. You should see the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Select your backend name and click the Next button. You should see the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Enter your admin user and click the ” Next” button. You should see the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Click on the Next button. You should see the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Check all settings and click the Next button. You will be redirected to the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Click on the Next button. You should see the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Enter your credentials for the Icinga IDO database and click the Next button. You should see the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Select your preferred options and click the Next button. You should see the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Select your monitoring security and click the Next button. You should see the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Review your configuration and click the Finish button. You should see the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Click the Login to Icinga Web 2 button. You should see the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Enter your admin username and password and click the Login button. You should see the following page:

How to Install the Icinga 2 Monitoring Software on Ubuntu 22.04 linux ubuntu

Conclusion

Congratulations! You have successfully installed and configured the Icinga2 Monitoring Server on Ubuntu 22.04. You can deploy Icinga2 in your infrastructure, add all monitoring servers, and monitor them via the Icinga Web 2 dashboard.