How to Install Icinga 2 on CentOS 8

Install Icinga 2 on CentOS 8

In this article, we will have explained the necessary steps to install and configure Icinga 2 on CentOS 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Icinga 2 is a free and open-source monitoring tool for monitoring servers, network resources. Icinga 2 checks the availability of your network resources, notifies users of outages and generates performance data for reporting. Icinga 2 can be used to monitor large and complex environments across multiple locations.

Install Icinga 2 on CentOS 8

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo dnf install epel-release
sudo dnf install 'dnf-command(config-manager)'
sudo dnf config-manager --set-enabled PowerTools
sudo dnf update

Step 2. Install Icinga 2 on CentOS 8 system.

Now we will install Icinga 2 by using our distribution’s package manager.

sudo dnf install icinga2 icinga2-selinux icinga2-ido-mysql vim-icinga2

After Icinga 2 installation was successful, it is usually to enable it and start its services. To start and enable its service, we will submit the command lines:

sudo systemctl enable icinga2
sudo systemctl start icinga2

Step 3. Install Nagios Plugins.

Icinga 2 does not know how to check external services without plugins. Now we install Nagios plugins using the below command:

sudo dnf install nagios-plugins-all

Step 4. Install MariaDB Database Server

Install the MariaDB package using the following command:

sudo apt install mariadb-server

After it’s installed, the MariaDB server should be automatically started. Use systemctl to check its status:

systemctl status mariadb

After installation, we have to improve MariaDB security by typing the following:

sudo mysql_secure_installation

Then enter yes/y to the following security questions:

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
    Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
    Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
    Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

Install Icinga 2 on CentOS 8

To connect to the MariaDB server through the terminal we can use the MariaDB client. To log in to the MariaDB server as the root user type:

$ mysql -u root -p

GRANT ALL PRIVILEGES ON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY 'your-passwd';

Then, enable Icinga 2 required modules:

sudo icinga2 feature enable command ido-mysql syslog

Next, import Icinga 2 Database:

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

Configure Database access:

sudo nano /etc/icinga2/features-available/ido-mysql.conf

Uncomment the lines and set access credentials:

 * The IdoMysqlConnection type implements MySQL support
 * for DB IDO.

object IdoMysqlConnection "ido-mysql" {
  user = "icinga"
  password = "your-passwd"
  host = "localhost"
  database = "icinga"

Then, start and enable icinga2 service:

sudo systemctl enable --now icinga2.service
sudo systemctl restart icinga2
sudo systemctl status icinga2

That’s all you need to do to install Icinga on CentOS 8. I hope you find this quick tip helpful. For further reading on Icinga 2, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.