Icinga 2 is a free and open-source monitoring tool for monitoring servers, network resources. With Icinga 2, you can configure alert on outages and able to generate the performance data.
Icinga 2 is very scalable, and you can monitor smaller to larger, complex environments across multiple locations.
Here, we will see how to install Icinga 2 on CentOS 8 / RHEL 8.
Enable EPEL Repository
Contents
Icinga packages depend on other packages that are distributed in the EPEL repository. So, configure the EPEL repository on CentOS 8 / RHEL 8.
CentOS 8
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm dnf config-manager --set-enabled PowerTools
RHEL 8
ARCH=$( /bin/arch ) subscription-manager repos --enable rhel-8-server-optional-rpms
subscription-manager repos --enable "codeready-builder-for-rhel-8-${ARCH}-rpms" dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
Add Icinga 2 Repository
Icinga provides Icinga 2 packages from its dedicated repository. So, install the Icinga repository configuration rpm to automatically configure the Icinga repository.
rpm --import https://packages.icinga.com/icinga.key dnf install -y https://packages.icinga.com/epel/icinga-rpm-release-8-latest.noarch.rpm
Install Icinga 2
After configuring the Icinga repository, install the Icinga 2 with dnf command.
dnf install -y icinga2
To start Icinga2 service, run:
systemctl start icinga2
To enable Icinga 2 service to start automatically on system startup, run:
systemctl enable icinga2
SELinux
If your system has SELinux enabled, then install the below package to have a targeted policy for Icinga 2.
dnf install -y icinga2-selinux
Install Nagios Plugins
Without plugins, Icinga 2 does not know how to monitor application services. So, install Nagios plugins to work with Icinga 2.
dnf install -y nagios-plugins-all
Firewall
Configure the firewall to allow client systems to send data to the Icinga 2 server.
firewall-cmd --permanent --add-port=5665/tcp firewall-cmd --reload
Configuring DB IDO MySQL
The DB IDO module for Icinga 2 takes care of exporting all configuration and status information to the database.
At present, MySQL and PostgreSQL are supported. Here, we will use the MySQL / MariaDB server as a database server.
Install Database Server
Install the MariaDB server (v10.3) from the OS repository.
READ: How To Install MariaDB v10.4 on CentOS 8 / RHEL 8
READ: How To Install MySQL 8 on CentOS 8 / RHEL 8
dnf install -y mariadb-server mariadb
Start and enable MariaDB service.
systemctl start mariadb systemctl enable mariadb
Perform the initial setup of MariaDB using the mysql_secure_installation command to setup database root password and other important security measures.
Install IDO modules for MySQL
Now, proceed to install IDO modules for MySQL using the following command.
dnf install -y icinga2-ido-mysql
Create Database for IDO modules
Login to MariaDB using the following command.
mysql -u root -p
Create a database for IDO modules. Please note down the database details as we need this when we set up the Icinga web 2 interface.
CREATE DATABASE icinga2; grant all privileges on icinga2.* to icinga2@localhost identified by 'icinga123'; FLUSH PRIVILEGES; quit
After creating the database, import the Icinga 2 IDO schema using the following command.
mysql -u root -p icinga2 < /usr/share/icinga2-ido-mysql/schema/mysql.sql
Enable IDO MySQL Module
By default, the IDO MySQL module (ido-mysql) is disabled. Let’s lists the available and enabled modules in Icinga 2.
icinga2 feature list
Output: Disabled features: api command compatlog debuglog elasticsearch gelf graphite ido-mysql influxdb livestatus opentsdb perfdata statusdata syslog Enabled features: checker mainlog notification
Enable ido-mysql module using the below command.
icinga2 feature enable ido-mysql
Also, enable the command feature, which helps Icinga web 2 interface or other Icinga add-ons to send commands to Icinga 2 via external command pipe.
icinga2 feature enable command
Configure IDO DB MySQL module
Once you have enabled the IDO module, the Icinga 2 places the new configuration file /etc/icinga2/features-enabled/ido-mysql.conf.
Edit the file to update the database credentials manually.
vi /etc/icinga2/features-enabled/ido-mysql.conf
Update the above file, as shown below.
user = "icinga2", password = "icinga123", host = "localhost", database = "icinga2"
Restart the Icinga 2 server to have this enabled features take effect.
systemctl restart icinga2
Conclusion
That’s All. I hope you have learned how to install Icinga 2 on CentOS 8 / RHEL 8. In our next article, we will install the Icinga web 2 interface.