CentLinux | Learn How to Install CentOS/Rocky Linux Servers

Sunday, January 12, 2020

How to Install Icinga 2 on CentOS 8

How to Install Icinga 2 on CentOS 8

Icinga 2 is an open-source computer and network monitoring software. It was originally forked from Nagios network monitoring application in 2009 and distributed under GNU GPL v2.

Being a fork of Nagios, Icinga has all the features of Nagios Core and it also has some additional features like modern Web 2.0 style user interface, database connectors (for MySQL, Oracle and PostgreSQL) and a REST API that lets SysAdmins integrate numerous extensions without complicated modifications.

Icinga developers also seek to reflect the community needs more closely by integrating patches more quickly.

In this article, we are writing a guide on how to install Icinga 2 on CentOS 8 and we are also configuring MariaDB as backend data store for our Network Monitoring Server by means of IDO (Icinga Data Out) module.

Instructions in this article are of advance level, if you are new to Linux world then we strongly recommend you to read Red Hat RHCSA 8 Cert Guide: EX200 (Certification Guide) by Pearson IT Certification. It will provides basic to intermediate knowledge about the RHEL (Red Hat Enterprise Linux) 8 or CentOS 8.

How to Install Icinga 2 on CentOS 8

Table of Contents:


Icinga 2 Features:

Some of the core features of Icinga 2 are.

  • Monitors network services (http, smtp, pop3, ping, etc.)
  • Monitors host system resources (CPU load, Memory usage, disk usage, etc.)
  • Monitors server components (switches, routers, humidity and temperature sensors,etc.)
  • Simple plugin design
  • Parallel service checks


Environment Specification:

We are using a CentOS 8 (minimal) virtual machine with following specification.

  • CPU - 3.4 Ghz (2 cores)
  • Memory - 2 GB
  • Storage - 20 GB
  • Operating System - CentOS 8.0
  • Hostname - icinga-2.recipes.com
  • IP Address - /24


Installing EPEL yum repository on CentOS 8:

Connect with icinga-2.recipes.com server as root user by using an ssh tool.

Icinga 2 requires Nagios Plugins, that are available in EPEL (Extra Packages for Enterprise Linux) yum repository, therefore we are installing EPEL yum repository.

# dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm


Installing MariaDB Server on CentOS 8:

We are installing MariaDB server to be used as the data store for Icinga 2.

# dnf install -y @mariadb/server

Start and enable MariaDB service.

# systemctl enable --now mariadb.service
Created symlink /etc/systemd/system/mysql.service â /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service â /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service â /usr/lib/systemd/system/mariadb.service.

Configure MariaDB server and set root user password.

# mysql_secure_installation


In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!


Installing Icinga 2 Official Yum Repository:

Icinga 2 rpms are provided within its own yum repository, therefore it is necessary to install their offical yum repository, if we want to install this network monitoring software by using dnf command.

# dnf install -y https://packages.icinga.com/epel/icinga-rpm-release-8-latest.noarch.rpm

Build cache for newly installed yum repositories.

# dnf makecache
CentOS-8 - AppStream                            4.6 kB/s | 4.3 kB     00:00
CentOS-8 - Base                                 5.2 kB/s | 3.9 kB     00:00
CentOS-8 - Extras                               4.5 kB/s | 1.5 kB     00:00
ICINGA (stable release for epel)                 43 kB/s |  66 kB     00:01
Extra Packages for Enterprise Linux 8 - x86_64  5.1 kB/s | 9.9 kB     00:01
Metadata cache created.


Installing Nagios Plugins on CentOS 8:

For collection of different metrics, we need commands provided by the respective Nagios plugins tools.

Nagios Plugins are available in EPEL yum repository. Since, we have already installed EPEL, therefore, we can now easily install Nagios Plugins using dnf commands.

# dnf install -y nagios-plugins-{http,ping,disk,users,swap,procs,ssh,load}

There are thousands of Nagios Plugins are freely available, but we are only installing the required plugins.


Installing Icinga 2 on CentOS 8:

We have installed Icinga 2 yum repository. Therefore, we can now install this Nagios alternative software by using dnf command.

# dnf install -y icinga2 icinga2-selinux icinga2-ido-mysql vim-icinga2

Check Icinga 2 installed features.

# icinga2 feature list
Disabled features: api command compatlog debuglog elasticsearch gelf graphite ido-mysql influxdb livestatus opentsdb perfdata statusdata syslog
Enabled features: checker mainlog notification


Configure Icinga 2 IDO to use MariaDB Data Store:

Connect with MariaDB server as root user.

# mysql -u root -p123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.3.11-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

Create a MariaDB database for Icinga 2 as follows.

MariaDB [(none)]> CREATE DATABASE icinga;
Query OK, 1 row affected (0.073 sec)

Create a user for Icinga 2 and grant complete privileges on icinga database.

MariaDB [(none)]> GRANT ALL PRIVILEGES ON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY 'Ahmer@1234';
Query OK, 0 rows affected (0.176 sec)

Reload privileges table and exit from MySQL prompt.

Query OK, 0 rows affected (0.066 sec)

MariaDB [(none)]> EXIT;

Import database from the script provided with the Icinga 2 software.

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

Configure IDO configurations according to our environment.

# vi /etc/icinga2/features-available/ido-mysql.conf

Uncomment and set directives as follows.

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

object IdoMysqlConnection "ido-mysql" {
  user = "icinga"
  password = "Ahmer@1234"
  host = "localhost"
  database = "icinga"

Enable IDO and other required features.

# icinga2 feature enable command ido-mysql syslog
Enabling feature command. Make sure to restart Icinga 2 for these changes to take effect.
Enabling feature ido-mysql. Make sure to restart Icinga 2 for these changes to take effect.
Enabling feature syslog. Make sure to restart Icinga 2 for these changes to take effect.

Enable and start Icinga 2 Service.

# systemctl enable --now icinga2.service
Created symlink /etc/systemd/system/multi-user.target.wants/icinga2.service â /usr/lib/systemd/system/icinga2.service.

Verify status of Icinga 2 Service.

# systemctl status icinga2.service
â icinga2.service - Icinga host/service/network monitoring system
   Loaded: loaded (/usr/lib/systemd/system/icinga2.service; enabled; vendor pre>
   Active: active (running) since Sat 2020-01-11 12:34:00 PKT; 27s ago
  Process: 14847 ExecStartPre=/usr/lib/icinga2/prepare-dirs /etc/sysconfig/icin>
 Main PID: 14857 (icinga2)
    Tasks: 13 (limit: 5948)
   Memory: 13.5M
   CGroup: /system.slice/icinga2.service
           ââ14857 /usr/lib64/icinga2/sbin/icinga2 --no-stack-rlimit daemon --c>
           ââ14872 /usr/lib64/icinga2/sbin/icinga2 --no-stack-rlimit daemon --c>
           ââ14873 /usr/lib64/icinga2/sbin/icinga2 --no-stack-rlimit daemon --c>

Jan 11 12:34:00 icinga-2.recipes.com icinga2[14857]: [2020-01-11 12:34:00 +0500>
Jan 11 12:34:00 icinga-2.recipes.com systemd[1]: Started Icinga host/service/ne>

We have successfully installed Icinga 2 on CentOS 8. Continue reading our next article for installation of Icinga Web 2 on CentOS 8.

If you find this article useful? Consider supporting us by Buy Me A Coffee

No comments:

Post a Comment

© 2023 CentLinux. All Rights Reserved.