How To Configure Icinga and Icinga Web on Ubuntu 16.04


In this article, we will configure Icinga and Icinga Web on Ubuntu 16.04 machine. Icinga is a very powerful, flexible and open source monitoring tool used to observe the health of the servers and services, uptime, CPU, Hard Disk Usage, and Memory and so on, Icinga can provide an overview status of the servers and services with notifications can maintain a performance data.

Pre-requisites

Ubuntu 16.04 server with Apache, PHP and MySQL Installed. An SSL will be required if we are setting up in the Public Environment as Icinga will have the sensitive information

Installing and Configuring Icinga

We will download and install the latest version of Icinga from the official repository which is maintained by the Icinga, to download the latest version of Icinga we needed to get the signing key and add to the local apt repo, the key will be used to verify the integrity of the downloaded file from the Icinga repository.

$ curl -sSL https://packages.icinga.com/icinga.key | sudo apt-key add -
OK

Now we will add the Icinga repository address to the local apt configuration file.

$ sudo vi /etc/apt/sources.list.d/icinga.list

And add the bellow lines to the file.

deb https://packages.icinga.com/ubuntu icinga-xenial main

Once, we save the file we will update the local apt repository with the below command –

$ sudo apt-get update
Output:
Hit:1 http://in.archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease
Get:3 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit:4 http://in.archive.ubuntu.com/ubuntu xenial-backports InRelease
Get:5 https://packages.icinga.com/ubuntu icinga-xenial InRelease [6,209 B]
Get:6 https://packages.icinga.com/ubuntu icinga-xenial/main amd64 Packages [3,708 B]
Get:7 https://packages.icinga.com/ubuntu icinga-xenial/main i386 Packages [3,702 B]
Fetched 116 kB in 1s (82.5 kB/s)Reading package lists... Done

Once the apt-get update gets the download information from the repository we just install the packages using the below command

$ sudo apt-get install icinga2 icinga2-ido-mysql
Output:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
aspell aspell-en dictionaries-common emacsen-common enchant
firebird2.5-common firebird2.5-common-doc freetds-common hunspell-en-us
libaspell15 libc-client2007e libenchant1c2a libfbclient2 libhunspell-1.3-0
libmcrypt4 libodbc1 libpq5 libqdbm14 librecode0 libsensors4 libsnmp-base
libsnmp30 libsybdb5 libtidy-0.99-0 libxmlrpc-epi0 libzip4 mlock
…
…
0 upgraded, 15 newly installed, 0 to remove and 153 not upgraded.
Need to get 4,904 kB of archives.
After this operation, 24.2 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Her we needed to enable Icinga ido-mysql Feature

We needed to select Yes and press

Here, we need to configure database for icinga ido-mysql with common configuration we needed to press Enter on Yes
…
…
Creating config file /etc/nagios-plugins/config/disk.cfg with new version
Creating config file /etc/nagios-plugins/config/dummy.cfg with new version
Creating config file /etc/nagios-plugins/config/ftp.cfg with new version
Creating config file /etc/nagios-plugins/config/http.cfg with new version
Creating config file /etc/nagios-plugins/config/load.cfg with new version
..
..
Creating config file /etc/nagios-plugins/config/telnet.cfg with new version
Creating config file /etc/nagios-plugins/config/users.cfg with new version
Setcap for check_icmp and check_dhcp worked!
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...

Now we also need to enable the Icinga database backend feature in the Icinga. icinga2 is the command used to enable or disable the features from the command line, below is the command to enable the features

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

Now restart the icinga2 to enable the features and check the status of the icinga2

$ sudo systemctl restart icinga2
$ sudo systemctl status icinga2
● icinga2.service - Icinga host/service/network monitoring system
Loaded: loaded (/lib/systemd/system/icinga2.service; enabled; vendor preset:
Active: active (running) since Wed 2017-06-28 15:22:02 IST; 7s ago
Process: 18344 ExecStartPre=/usr/lib/icinga2/prepare-dirs /usr/lib/icinga2/ici
Main PID: 18408 (icinga2)
Tasks: 12 (limit: 512)
Memory: 11.1M
CPU: 1.730s
CGroup: /system.slice/icinga2.service
├─18408 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rli
└─18430 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rli

Install Icinga Web Interface

Icinga core is installed and configured, and it’s not usable without a web console or interface, the web interface provides the overview of the servers or hosts health and services and also can schedule, acknowledge the downtime for the hosts and servers and can also allow testing the health status manually with notifications from the browser.

$ sudo apt-get install icingaweb2
Output:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
aspell aspell-en dictionaries-common emacsen-common enchant
firebird2.5-common firebird2.5-common-doc freetds-common hunspell-en-us
libaspell15 libc-client2007e libenchant1c2a libfbclient2 libhunspell-1.3-0
libmcrypt4 libodbc1 libpq5 libqdbm14 librecode0 libsensors4 libsnmp-base
libsnmp30 libsybdb5 libtidy-0.99-0 libxmlrpc-epi0 libzip4 mlock
Use 'sudo apt autoremove' to remove them.
…
…
Setting up php-mysql (1:7.0+35ubuntu6) ...
Setting up ttf-dejavu-core (2.35-1) ...
Setting up php-icinga (2.4.1-1~ppa1604+1) ...
Setting up icingacli (2.4.1-1~ppa1604+1) ...
Setting up icingaweb2-common (2.4.1-1~ppa1604+1) ...
Adding system-group for icingaweb2
Adding user `www-data' to group `icingaweb2' ...
Adding user www-data to group icingaweb2
Done.
Setting up icingaweb2 (2.4.1-1~ppa1604+1) ...
apache2_invoke: Enable module rewrite
apache2_invoke: Enable configuration icingaweb2
Setting up icingaweb2-module-doc (2.4.1-1~ppa1604+1) ...
Setting up icingaweb2-module-monitoring (2.4.1-1~ppa1604+1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...

Once, the installation is successful we needed to update the php.ini file with the time zone settings.

$ sudo vi /etc/php/7.0/apache2/php.ini
...
date.timezone = America/New_York
...

Save and Restart the Apache to get the changes update.

$ sudo systemctl restart apache2

Configuring the Icinga Web Interface.

We needed to create a setup token from the command line using icingacli command, where this key is used to authorize the web interface for icinga, below is the command to create

$ sudo icingacli setup token create
1834c3d0sd2343ab

We needed to access the Icinga using the browser http://your-ip-address/icingaweb2

We needed to enter the setup token which we generated earlier and Click Next.

Now we can see the Modules, here in the demo we will select only one module Monitoring and click Next

Now we can see the PHP Environment status where we can see some error regarding PostgreSQL, where we can ignore them as we are using MySQL as database and click Next.

Here we select the Authentication, Here we select authentication as Database, where we have LDAP and External.

Enter the details like database name, database username, database password, Once we enter we click Validate Configuration and Click Next.

Here we can select Authentication Backend, Click on Next.

Here we can create Administration account for Icinga Web 2. Enter the information and click Next.

Here we can configure the application configuration, click Next.

Here we configure the Monitoring module for Icinga Web 2, Click Next

Here we configure Monitoring Backend, Click Next.

Here we configure Monitoring IDO Resource. Click Next.

Here we configure Database for IDO

Configure the Command Transport Method, Monitoring Interface Security, and Module Configuration Summary, Once we see the summary page click on Login to Icinga Web 2.

Once you login into the Icinga Server, the main interface will look like this and it loads Icinga Web with Critical Error and Recently recovered services.

Configuring Email, Notifications.

We needed to configure the email so that we receive the alerts if something goes wrong with the servers.

To get the email notification we needed to update the email address in the Icinga

$ sudo nano /etc/icinga2/conf.d/users.conf
/**
* The example user 'icingaadmin' and the example
* group 'icingaadmins'.
*/
object User "icingaadmin" {import "generic-user"
display_name = "Icinga 2 Admin"
groups = [ "icingaadmins" ]
email = "smikcp@gmail.com"
}
object UserGroup "icingaadmins" {
display_name = "Icinga 2 Admin Group"
}

We needed to restart the Icinga Services to make the changes effect, below is the command to restart the services

$ sudo systemctl restart icinga2

In this article, we have learned how to configured and installed Icinga, Icinga web with email configuration and email notification for any alerts, in the demo we only monitor the Icinga host only.

Advertisements