November 24, 2020
How to Install Icinga 2 on CentOS 8

How To Install Icinga 2 On CentOS 8

On this tutorial we will discuss how to install Icinga2 on Linux CentOS 8.

Introduction

Icinga 2 is a free and open-source monitoring tool. It is designed for scalable and extensible monitoring servers and network from smaller to larger and complex environments across multiple locations. Icinga 2 checks the availability of systems and network resources, notifies users incase outages happened, and generates performance data for reporting.

On this article we will discuss how to install Icinga 2 on Centos 8 Linux operating system. The installation process will be consist of several steps as described below :

  1. Install Icinga 2 Repository
  2. Install EPEL (Extra Package Enterprise Linux)
  3. Install Icinga 2
  4. Install Nagios Plugins
  5. SELinux CentOS
  6. Configuring DB IDO (Database Icinga Data Output)



Install Icinga 2 Repository

The first step of Icinga 2 installation is to install the Icinga 2 repository. We need to add the Icinga repository to our package management configuration. The preferred way of doing this is to use the official package repositories depending on which operating system and distribution we are running (our environment is CentOS 8).

[root@otodiginet ~]# dnf install https://packages.icinga.com/epel/icinga-rpm-release-8-latest.noarch.rpm
Last metadata expiration check: 0:03:16 ago on Sat 31 Oct 2020 06:18:19 PM PDT.
icinga-rpm-release-8-latest.noarch.rpm 4.2 kB/s | 9.5 kB 00:02
install Icinga2 repository

Install EPEL (Extra Packages for Enterprise Linux)

CentOS 8 additionally needs the PowerTools repository for EPEL. We will execute the following commands below :

[root@otodiginet ~]# dnf install 'dnf-command(config-manager)'
[root@otodiginet ~]# dnf config-manager --set-enabled PowerTools
[root@otodiginet ~]# dnf install epel-release

Install Icinga 2

We will install Icinga 2 by using our distribution’s package manager. For this purpose, we will submit the command line below :

[root@otodiginet ~]# dnf install icinga2
ICINGA (stable release for epel) 5.1 kB/s | 165 kB 00:32
Last metadata expiration check: 0:00:03 ago on Sat 31 Oct 2020 06:27:10 PM PDT.
Dependencies resolved.

The output will be as follow :

Installed:
boost-context-1.66.0-7.el8.x86_64 boost-coroutine-1.66.0-7.el8.x86_64 icinga2-2.12.1-1.el8.icinga.x86_64
icinga2-bin-2.12.1-1.el8.icinga.x86_64 icinga2-common-2.12.1-1.el8.icinga.x86_64
Complete!
dnf install icinga2
icinga 2 installation on Centos 8 was compelted done.

Icinga 2 Enabling and Starting Services

After Icinga 2 installation was completed done, it is usually to enable it and start its services. To start and enable it service, we will submit the command lines : systemctl [enable | start | status] icinga2 as shown below.

root@otodiginet ~]# systemctl enable icinga2
Created symlink /etc/systemd/system/multi-user.target.wants/icinga2.service → /usr/lib/systemd/system/icinga2.service.
[root@otodiginet ~]# systemctl start icinga2
[root@otodiginet ~]# systemctl status icinga2
● icinga2.service - Icinga host/service/network monitoring system
Loaded: loaded (/usr/lib/systemd/system/icinga2.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2020-10-31 18:30:39 PDT; 8s ago
Process: 51074 ExecStartPre=/usr/lib/icinga2/prepare-dirs /etc/sysconfig/icinga2 (code=exited, status=0/SUCCESS)
Main PID: 51082 (icinga2)
Tasks: 21 (limit: 49614)
Memory: 14.4M
CGroup: /system.slice/icinga2.service
├─51082 /usr/lib64/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e /var/log/icinga2/error.log
├─51115 /usr/lib64/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e /var/log/icinga2/error.log
└─51124 /usr/lib64/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e /var/log/icinga2/error.log
Oct 31 18:30:39 otodiginet icinga2[51082]: [2020-10-31 18:30:39 -0700] information/ConfigItem: Instantiated 235 CheckCommand>
Oct 31 18:30:39 otodiginet icinga2[51082]: [2020-10-31 18:30:39 -0700] information/ConfigItem: Instantiated 3 TimePeriods.
Oct 31 18:30:39 otodiginet icinga2[51082]: [2020-10-31 18:30:39 -0700] information/ConfigItem: Instantiated 1 UserGroup.
Oct 31 18:30:39 otodiginet icinga2[51082]: [2020-10-31 18:30:39 -0700] information/ConfigItem: Instantiated 1 User.
Oct 31 18:30:39 otodiginet icinga2[51082]: [2020-10-31 18:30:39 -0700] information/ConfigItem: Instantiated 11 Services.
Oct 31 18:30:39 otodiginet icinga2[51082]: [2020-10-31 18:30:39 -0700] information/ConfigItem: Instantiated 3 ServiceGroups.
Oct 31 18:30:39 otodiginet icinga2[51082]: [2020-10-31 18:30:39 -0700] information/ConfigItem: Instantiated 1 ScheduledDownt>
Oct 31 18:30:39 otodiginet icinga2[51082]: [2020-10-31 18:30:39 -0700] information/ScriptGlobal: Dumping variables to file '>
Oct 31 18:30:39 otodiginet icinga2[51082]: [2020-10-31 18:30:39 -0700] information/cli: Closing console log.
Oct 31 18:30:39 otodiginet systemd[1]: Started Icinga host/service/network monitoring system.

Install Nagios Plugins

Icinga 2 does not know how to check external services without plugins. The Monitoring Plugins Project provides an extensive set of plugins which can be used with Icinga 2 to check whether services are working properly.

[root@otodiginet ~]# dnf install nagios-plugins-all
Last metadata expiration check: 0:07:22 ago on Sat 31 Oct 2020 06:27:10 PM PDT.
Dependencies resolved.
Package Architecture Version Repository Size
Installing:
nagios-plugins-all x86_64 2.3.3-4.el8 epel 24 k
install nagios-plugins

Install Icinga 2 SELinux

Icinga 2 has its own SELinux policy. icinga2-selinux is a policy package for Red Hat Enterprise Linux 7 and derivatives. The package runs the targeted policy which confines Icinga 2 including enabled features and running commands.

[root@otodiginet ~]# dnf install icinga2-selinux
Last metadata expiration check: 13:20:40 ago on Sat 31 Oct 2020 06:27:10 PM PDT.
Dependencies resolved.
Package Arch Version Repository Size
Installing:
icinga2-selinux x86_64 2.12.1-1.el8.icinga icinga-stable-release 63 k
install icinga SELinux

Configuring DB IDO (Database Icinga Data Output)

The DB IDO (Database Icinga Data Output) feature for Icinga 2 takes care of exporting all configuration and status information into a database. Icinga 2 is supported by MySQL and PostgreSQL database for storing its backend data, while Icinga is preparing Icinga DB for this purpose. For more information about Icinga DB. On this tutorial we will use MySQL 8 as our Icinga backend database.



1. Install Database Server

For MySQL 8 installation on CentOS 8, has been discussed on How To Install MySQL 8 On CentOS 8 article. To ensure if the MySQL database was installed on our system, we will verfiy it service by submitting command line systemclt status mysqld.

2. Installing the IDO modules for MySQL

The next step is to install the icinga2-ido-mysql package using your distribution’s package manager.

[root@otodiginet ~]# yum install icinga2-ido-mysql
Last metadata expiration check: 0:41:45 ago on Sun 01 Nov 2020 06:52:39 AM PST.
Dependencies resolved.
Package Arch Version Repository Size
Installing:
icinga2-ido-mysql x86_64 2.12.1-1.el8.icinga icinga-stable-release 119 k
Transaction Summary
Install 1 Package
Total download size: 119 k
Installed size: 523 k
Is this ok [y/N]: y
Downloading Packages:
icinga2-ido-mysql-2.12.1-1.el8.icinga.x86_64.rpm 20 kB/s | 119 kB 00:05
Total 20 kB/s | 119 kB 00:05
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : icinga2-ido-mysql-2.12.1-1.el8.icinga.x86_64 1/1
Running scriptlet: icinga2-ido-mysql-2.12.1-1.el8.icinga.x86_64 1/1
Verifying : icinga2-ido-mysql-2.12.1-1.el8.icinga.x86_64 1/1
Installed products updated.
Installed:
icinga2-ido-mysql-2.12.1-1.el8.icinga.x86_64
Complete!

3. Set up a MySQL database

Set up a MySQL database for Icinga 2, we will login to MySQL database as root account and create a database called as icinga.

[root@otodiginet ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 54
Server version: 8.0.21 Source distribution
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE DATABASE icinga;
Query OK, 1 row affected (0.01 sec)
mysql> create user 'icinga' identified by 'Icinga123!';
Query OK, 0 rows affected (0.02 sec)
mysql> grant SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE
-> on icinga.* to 'icinga';
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
Create Database Icinga 2

After setting up MySQL database, the we import the Icinga 2 IDO schema using the following command.

root@otodiginet schema]# mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/mysql.sql
Enter password:
root@otodiginet schema]# icinga2 feature enable ido-mysql
Import icinga 2 IDO Schema - MySQL
Import icinga 2 IDO Schema – MySQL
[root@otodiginet ~]# cd /usr/share/icinga2-ido-mysql
[root@otodiginet icinga2-ido-mysql]# ls -ltr
total 0
drwxr-xr-x. 3 root root 38 Nov 1 07:34 schema
[root@otodiginet icinga2-ido-mysql]# cd schema/
[root@otodiginet schema]# ls -ltr
total 68
-rw-r--r--. 1 root root 66279 Oct 15 02:56 mysql.sql
drwxr-xr-x. 2 root root 177 Nov 1 07:34 upgrade
[root@otodiginet schema]# more mysql.sql

-- mysql.sql
-- DB definition for IDO MySQL
-- Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: icinga
icinga 2 schema
Icinga 2 Schema

4. Enabling IDO MySQL Module

The configuration file is located on /etc/icinga2/features-available/ido-mysql.conf file. We can update it as we have set.

We will restart the Icinga 2 service to take affect after we havet taken an udpate. By submitting command line below :

[root@otodiginet schema]# icinga2 feature enable ido-mysql
Enabling feature ido-mysql. Make sure to restart Icinga 2 for these changes to take effect.
[root@otodiginet schema]# systemctl restart icinga2
[root@otodiginet schema]# systemctl status icinga2
Enabling IDO-Mysqk Icinga2

Conclusion

So far, the Icinga 2 installation was completed done. To complete tutorial for using Icinga 2, we need the Icinga Web 2 interface installation. The Icinga Web 2 installation on CentOS 8 will be available on different article.

Share this article via :

Leave a Reply

Your email address will not be published. Required fields are marked *