Icinga 2 is a free and open source monitoring tool which helps you to monitor network resources, get an alert on outages, also be able to generate the performance data.
Icinga 2 is very scalable, and you can monitor small to larger, complex environments across multiple locations.
Icinga 2 supports all major distributions such as Debian, Ubuntu, CentOS / RHEL, Fedora, openSUSE, SLES, Gentoo, FreeBSD, and ArchLinux.
This post briefly covers the installation and configuration of Icinga 2 on CentOS 7 / RHEL 7.
Switch to the root user.
$ sudo su -
Icinga packages depend on other packages (ex. Nagios plugins) which are distributed in EPEL repository. So, configure the EPEL repository on CentOS 7 / RHEL 7.
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
In addition to this, enable the optional and extras repositories on RHEL 7.
subscription-manager repos --enable rhel-7-server-optional-rpms subscription-manager repos --enable rhel-7-server-extras-rpms
Add Icinga 2 Repository
Contents
Icinga provides its official repository for their packages. So, install repository rpm
rpm --import https://packages.icinga.com/icinga.key yum install https://packages.icinga.com/epel/icinga-rpm-release-7-latest.noarch.rpm
Install Icinga 2
yum -y install icinga2
To start Icinga2 service, run:
systemctl start icinga2
To set Icinga 2 service to start automatically on system startup, run:
systemctl enable icinga2
SELinux
If the system has SELinux enabled, then Install the below package to have targeted policy for Icinga 2.
yum install -y icinga2-selinux
Install Nagios Plugins
Without the plugins, Icinga 2 does not know how to monitor the external services. So install Nagios plugins on top of Icinga 2.
yum -y install nagios-plugins-all
Configuring DB IDO MySQL
The DB IDO module for Icinga 2 takes care of exporting all the configuration and status information to the database; we need to have database server for this requirement.
At present, MySQL and PostgreSQL are supported. Here, we will use the MySQL server as a database server.
If you already have a MySQL server on your system, you can skip the below step.
yum -y install mariadb-server mariadb
Start and enable MariaDB service.
systemctl start mariadb systemctl enable mariadb
Install IDO modules for MySQL
Now, install IDO modules for MySQL using the following command. You can find the icinga2-ido-mysql package in Icinga 2 repository.
yum -y install icinga2-ido-mysql
Create Database for Icinga 2
Login to MariaDB using the following command.
mysql -u root -p
Create a database for IDO modules, and this is used when you set up the Icinga2 web interface.
CREATE DATABASE icinga2; grant all privileges on icinga2.* to icinga2@localhost identified by 'icinga123'; FLUSH PRIVILEGES; quit
After creating the database, you shall 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
Let’s lists the available and enabled features in Icinga 2.
icinga2 feature list
Output:
Disabled features: api command compatlog debuglog elasticsearch gelf graphite influxdb livestatus opentsdb perfdata statusdata syslog Enabled features: checker ido-mysql mainlog notification
You can see that ido-mysql is already enabled.
If ido-mysql is not enabled on your system, then enable it using below command.
icinga2 feature enable ido-mysql
Also, enable the command feature which helps Icinga web interface and other Icinga add-ons to send commands to Icinga 2 via the external command pipe.
icinga2 feature enable command
Configure IDO DB MySQL module
Once you have enabled the IDO modules in Icinga 2, the Icinga 2 places the new configuration file at /etc/icinga2/features-enabled/ido-mysql.conf in which you need to update the database credentials manually.
vi /etc/icinga2/features-enabled/ido-mysql.conf
Update the above file shown like below.
user = "icinga2", password = "icinga123", host = "localhost", database = "icinga2"
Restart the Icinga 2 instance to have this enabled features take effect.
systemctl restart icinga2
Check the status of Icinga 2 service.
systemctl status icinga2
Output:
● icinga2.service - Icinga host/service/network monitoring system Loaded: loaded (/usr/lib/systemd/system/icinga2.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2018-09-04 05:00:38 UTC; 23h ago Main PID: 11656 (icinga2) CGroup: /system.slice/icinga2.service ├─ 4520 /usr/lib64/nagios/plugins/check_ping -H 10.142.0.4 -c 5000,100% -w 3000,80% ├─ 4521 /usr/bin/ping -n -U -W 30 -c 5 10.142.0.4 ├─11656 /usr/lib64/icinga2/sbin/icinga2 --no-stack-rlimit daemon -e └─11690 /usr/lib64/icinga2/sbin/icinga2 --no-stack-rlimit daemon -e Sep 05 04:43:10 rhicinga2server icinga2[11656]: mail not found in $PATH. Consider installing it. Sep 05 04:43:10 rhicinga2server icinga2[11656]: [2018-09-05 04:35:29 +0000] information/WorkQueue: #10 (Json...in); Sep 05 04:43:10 rhicinga2server icinga2[11656]: [2018-09-05 04:35:30 +0000] information/WorkQueue: #7 (IdoMy...in); Sep 05 04:43:10 rhicinga2server icinga2[11656]: [2018-09-05 04:35:38 +0000] information/ConfigObject: Dumpin...ate' Sep 05 04:43:10 rhicinga2server icinga2[11656]: [2018-09-05 04:40:29 +0000] information/WorkQueue: #6 (ApiLi...in); Sep 05 04:43:10 rhicinga2server icinga2[11656]: [2018-09-05 04:40:29 +0000] information/WorkQueue: #5 (ApiLi...in); Sep 05 04:43:10 rhicinga2server icinga2[11656]: [2018-09-05 04:40:38 +0000] information/ConfigObject: Dumpin...ate'
Firewall
Configure the firewall to allow Icinga 2 clients to communicate with Icinga 2 server.
firewall-cmd --permanent --add-port=5665/tcp firewall-cmd --reload
We will configure the Icinga 2 web interface in our next tutorial.
READ: How To Setup Icinga Web 2 on CentOS 7 / RHEL 7
That’s All.