How to install Icinga 2 and Icinga 2 web on CentOS 7?

0
8657
monitoring

Icinga is an open source enterprise monitoring system that monitors networks and any significant network resources, notifies the user of errors, recoveries and generates information performance for reporting.

It was originally created as a fork of the Nagios system monitoring application in 2009. The Icinga developers also seek to reflect community needs more closely and to integrate patches more quickly.

Why Icinga? To gain control over the resources available on our network (Servers, Switches, Routers, etc.), which would prevent possible failures before they occur.

Some of its characteristics are:

  • Performance oriented: Icinga 2 is built to be fast. Thanks to its multithreaded design, it can run thousands of checks each second without any sign of CPU strain.
  • Distributed: combine high availability clusters with a distributed setup, and you have a best practice scenario for large and complex environments.
  • Rule based Configuration:monitoring as code with dynamic configurations. Apply rules to hosts and services to create a continuous monitoring environment.

Installation on CentOS 7

Adding Icinga repository and installing Icinga2

There is an Icinga repository for Red Hat Linux, and therefore it is compatible with CentOS. Add the repository:

               sudo -i

Then we enter our password and we are already a root user.

1.- Root privileges
1.- Root privileges

After that, we wrote the following:

               yum install https://packages.icinga.com/epel/icinga-rpm-release-7-latest.noarch.rpm

2.- Adding repository
2.- Adding repository

For this tutorial you need to have the EPEL repository activated, if you do not have it activated you can do it with the following command:

               yum install epel-release

Once the installation process is complete, we proceed to install Icinga2:

              yum install icinga2

3.- Installing Icinga2
3.- Installing Icinga2

Once the package is installed, we proceed to start and enable the service.

             systemctl start icinga2

And:

             systemctl enable icinga2

4.- Starting icinga2 service
4.- Starting icinga2 service

By default, the installation of icinga2 enables three functionalities: checker, notification and maillog. With the following instruction, we can see all the features:

             icinga2 feature list

5.- Icinga2 features
5.- Icinga2 features

As it was said before, Icinga is a Nagios fork, bringing as an advantage the compatibility with its plugins. Thanks to the EPEL repository, it’s just a command.

              yum install nagios-plugins-all

6.- Installing nagios plugins
6.- Installing nagios plugins

If we manage CentOS security with the selinux control system.

             yum install icinga2-selinux

Then we must restart the service

             systemctl restart icinga2

7.- Restarting icinga2
7.- Restarting icinga2

DB IDO on Icinga2 – Installing MariaDB

Icinga2 works with a DBMS that can be either MariaDB or postgreSQL. In this case we will use MariaDB, if we don’t have it installed, we must do it:

               yum install mariadb-server mariadb

8.-Installing MariaDB
8.-Installing MariaDB

After that, we must to enable it and start it:

             systemctl enable mariadb

And:

             systemctl start mariadb

9.-Enabling MariaDB
9.-Enabling MariaDB

With the mysql_secure_installation script we can define the password and other options of MariaDB. We answer Y,N,Y,Y.

                mysql_secure_installation

10.- Mysql_secure_installation
10.- Mysql_secure_installation

At this point we must install the Ido-mysql module or functionality:

              yum install icinga2-ido-mysql

11.- Installing module ido-mysl
11.- Installing module ido-mysl

Now we will create the user and database dedicated to icinga2. We’re accessing the mariadb console:

mysql -u root -p

Once logged in, we proceed to create the database:

               CREATE DATABASE icinga2;

And later, we will create the user dedicated to icinga, with his password and with permissions to alter everything in the icinga2 database:

              GRANT ALL PRIVILEGES ON icinga2.* TO ‘icinga2user’@’localhost’ IDENTIFIED BY ‘icinga2pss’;

12.- Creating user and database
12.- Creating user and database

Now we must repeat the process but for icinga web:

               CREATE DATABASE icinga2web;

               GRANT ALL PRIVILEGES ON icinga2web.* TO ‘icinga2webuser’@’localhost’ IDENTIFIED BY ‘icinga2webpss’;

And finally, we must to refresh all privileges:

               FLUSH PRIVILEGES;

13.- FLUSH PRIVILEGES
13.- FLUSH PRIVILEGES

We leave the mariadb console with exit. And to import the mysql ido schema into our mariadb configuration, we write:

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

14.- Importing database schema
14.- Importing database schema

We enabled the icinga2 module gone mysql and then restarted the service.

              icinga2 feature enable ido-mysql

After that:

              systemctl restart icinga2

15.- Restarting icinga2
15.- Restarting icinga2

Instalando Icinga 2 Web

Until now we have installed the server part of Icinga2, now it is the turn of the web interface that works with a web server. We chose apache in this tutorial, installed it, enabled it and started the service.

               yum install httpd

16.- Installing Apache
16.- Installing Apache

To enable it:

                  systemctl enable httpd

and to start it:

                 systemctl start httpd

17.- Starting apache
17.- Starting apache

And we execute the following commands to enable the port in the firewall:

              firewall-cmd –add-service=http

And:

             firewall-cmd –permanent –add-service=http

18.- Firewall
18.- Firewall

Icinga2web uses REST API for its internal processes and we must enable it to get full functionality.

We enabled it with the command:

             icinga2 api setup

19.- Enabling api rest
19.- Enabling api rest

Now we will edit the file: api-users to define username and password:

              nano /etc/icinga2/conf.d/api-users.conf

20.- Editing file
20.- Editing file

We replace user and password with the one we want.

In my case:

21.- File edited
21.- File edited

Another file we need to edit is the ido-mysql.conf to match the mariadb parameters we have configured.

In this case the file looks like this.

22.-ido-mysql.conf file
22.- ido-mysql.conf file

And now, we restart the icinga2 service.

             systemctl restart icinga2

Now we must enable the SCL repository to continue with the installation in an optimal way.

              yum install centos-release-scl

23.-Adding SCL repository
23.-Adding SCL repository

We proceed to install Icinga Web 2

            yum install icingaweb2 icingacli

24.-Installing Icinga2web
24.-Installing Icinga2web

If you use SELinux, then you will also need to install:

               yum install icingaweb2-selinux

The next thing you need to do is to install packages to work with FPM (FastCGI Process Manager):

               yum install rh-php71-php-fpm

Start the service:

              systemctl start rh-php71-php-fpm.service

And enable it:

              systemctl enable rh-php71-php-fpm.service

Now the module for mysql:

              yum install rh-php71-php-mysqlnd

And restart the service:

              systemctl restart rh-php71-php-fpm.service

26.- Restarting services
26.- Restarting services

We must now create a token that we will use in the web installer.

               icingacli setup token create

27.- Generating token
27.- Generating token

Finally we must restart apache

             systemctl restart httpd

It is highly recommended to modify the timezone in /etc/opt/rh/rh-php71/php.ini. In my case I’ll put America/caracas.

            nano /etc/opt/rh/rh-php71/php.ini

28.- Setting timezone
28.- Setting timezone

We restart the apache services and the php fpm.

               systemctl restart httpd

               systemctl restart rh-php71-php-fpm

And with this we can complete the installation from our web browser.

              http://IP_SERVER/icingaweb2/

In that initial screen we must add the token we have generated and click on next.

29.- Icinga2 web
29.- Icinga2 web

The following screen shows the active modules: Activate Doc and Monitoring:

 

30.- Modules
30.- Modules

On the next screen, verify that we meet the software requirements.

31.- Icinga2 web
31.- Icinga2 web

Next it asks us the form of authentication: we choose database.

32.- continuing the installation
32.- continuing the installation

Next, on the next screen, we will place the requested parameters of mariadb. Click on next.

33.- Mariadb parameters
33.- Mariadb parameters

The next screen is for naming the backend. We leave it the same. Click on next.

34.- backend
34.- backend

Now it’s time to set up the administrative account

35.- administrative account
35.- administrative account

It is the turn of the log. We left everything the same.

36.- Log
36.- Log

Check that everything is on the screen shown and click next.

37.- Next screen
37.- Next screen

And now, monitoring module:

38.- Monitoring module
38.- Monitoring module

The screen that will be shown is the backend monitoring screen, we leave everything the same.

39.- Monitoring backend
39.- Monitoring backend

In the next screen, we must place the parameters of MariaDB for icinga.

40.- Icinga mariaDB
40.- Icinga mariaDB

Now we must configure command transport with the parameters that we configure in the file: etc/icinga2/conf.d/api-users.conf

41.- Command transport
41.- Command transport

On the next screen we leave it the same:

42.- Monitoring security
42.- Monitoring security

we’ll see the summary and that’s it.

43.- Summary
43.- Summary

We have already successfully completed the installation process.

44.- Success!!!
44.- Success!!!

Now we can log in.

45.- Icinga loging
45.- Icinga loging

And we can finally get into the dashboard. If we can see it, it means everything went great.

46.- Dashboard
46.- Dashboard

Icinga2 is a great Nagios-based network monitoring program. Its installation under CentOS is a bit long but the process is not complex and does not require much effort.

Please share this tutorial on social networks for your friends to take advantage of.

Spread the love
  • 7
    Shares

PS. If you like this post please share it with your friends on the social networks using the buttons above.Thanks.

LEAVE A REPLY

Please enter your comment!
Please enter your name here