ICINGA2 is an open source monitoring system which checks the availability of your network resources, services, notifies users of outages and generates performance data for reporting. It is an advanced form of Nagios and it has a better web interface compared to it. It is developed with a much user-friendly web interface with more options and it is more responsive and customizable. Above all, the communication between the monitoring server and the client nodes has become more secure in this version.
In this article, I'll explain how to set up an Icinga2 server with Web 2 interface on Ubuntu 16.04 server. Let's walk through the step by step instructions on how to build our monitoring system.
Adding Repositories
Firs of all, we need to add our Icinga2 repositories to our server. We need to enable the add-repository feature and then add its repositories to our repository packages and update the packages.
root@ubuntu:~# apt install software-properties-common
root@ubuntu:~# add-apt-repository ppa:formorer/icinga
root@ubuntu:~#apt-get update
Installing Icinga2
Now we can install from the added repository.
root@ubuntu:~# apt-get install icinga2
Once the installation is complete. Make sure the service is up and running fine.
root@ubuntu:~# systemctl enable icinga2.service
Synchronizing state of icinga2.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable icinga2
root@ubuntu:~# systemctl start icinga2.service● icinga2.service - Icinga host/service/network monitoring system
Loaded: loaded (/lib/systemd/system/icinga2.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2016-06-26 07:18:44 UTC; 4h 2min ago
Process: 29178 ExecStartPre=/usr/lib/icinga2/prepare-dirs /usr/lib/icinga2/icinga2 (code=exited, status=0/SUCCESS)
Main PID: 29262 (icinga2)
Tasks: 16 (limit: 512)
CGroup: /system.slice/icinga2.service
└─29262 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon -e
Enabling the Feature list
By default, Icinga2 enables the following features. But we can confirm the enabled settings by running this command as below:
root@ubuntu:~# icinga2 feature list
Disabled features: api command compatlog debuglog gelf graphite icingastatus livestatus opentsdb perfdata statusdata syslog
Enabled features: checker mainlog notificationThe following features are enabled by default:
Checker : This feature enables the execution of checks.
Mainlog: This feature enables the logging.
Notification : This feature enables notification mechanism.
Install Icinga2 plugin
Icinga2 will collect the service information based on the monitoring plugins. Here we're installing nagios plugins for this function.
root@ubuntu:~# apt-get install nagios-plugins
Installing Data Output (IDO) Module
I'm using MySQL as the external database. Hence, we need to install the MySQL IDO module which is used for Icinga2 web interface. It is used for exporting all configuration and status information into its database. We need to install MySQL on our server, if it's not installed before.
root@ubuntu:~# apt-get install mysql-server-5.7
root@ubuntu:~# apt-get install icinga2-ido-mysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
mysql-server
The following NEW packages will be installed:
icinga2-ido-mysql
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/113 kB of archives.
After this operation, 686 kB of additional disk space will be used.
Preconfiguring packages ...
Determining localhost credentials from /etc/mysql/debian.cnf: succeeded.
Selecting previously unselected package icinga2-ido-mysql.
(Reading database ... 27776 files and directories currently installed.)
Preparing to unpack .../icinga2-ido-mysql_2.4.1-2ubuntu1_amd64.deb ...
Unpacking icinga2-ido-mysql (2.4.1-2ubuntu1) ...
Setting up icinga2-ido-mysql (2.4.1-2ubuntu1) ...
Determining localhost credentials from /etc/mysql/debian.cnf: succeeded.
dbconfig-common: writing config to /etc/dbconfig-common/icinga2-ido-mysql.conf
dbconfig-common: flushing administrative password
Once the IDO module is installed. We need to setup our MySQL DB to accept the values using this module. I created a database named "Icinga2" with the username "Icinga2" and password "Icinga123"
root@ubuntu:~# mysql -u root -p
mysql> Create database icinga2;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga2.*TO 'icinga2'@'localhost' IDENTIFIED BY 'icinga123';
mysql> flush privileges;root@ubuntu:~# icinga2 feature enable ido-mysql
warning/cli: Feature 'ido-mysql' already enabled.
After enabling this module and creating our database we need to restart our Icinga2 service. Please make sure the IDO MySQL configuration file is properly set with correct DB credentials.
root@ubuntu:~# cat /etc/icinga2/features-enabled/ido-mysql.conf
/**
* The db_ido_mysql library implements IDO functionality
* for MySQL.
*/library "db_ido_mysql"
object IdoMysqlConnection "ido-mysql" {
user = "icinga2",
password = "icinga123",
host = "localhost",
database = "icinga2"
}
Installing Icinga Web2 Plugin
In Ubuntu 16.05, PHP 7.0 is the default version, there are a lot more compactablity issues for Icinga2 with PHP 7.0. Hence, prior to this installation, we need to install PHP 5.6 version. For installing PHP 5.6 on my server. I need to enable a "ondrej/php" repository. Please see the steps below:
root@ubuntu:/usr#add-apt-repository ppa:ondrej/php
root@ubuntu:/usr#apt-get install php5.6
root@ubuntu:/usr# php -v
PHP 5.6.22-4+deb.sury.org~xenial+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
I'm going to use MySQL database to save all instincts of my Icinga2 Web interface. For that, create a database and grant all privileges for the user on that DB as below:
root@ubuntu:/usr/share/icingaweb2# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.7.11-0ubuntu6 (Ubuntu)Copyright (c) 2000, 2016, 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>
mysql> create database icingawebdb;mysql> GRANT SUPER ON *.* TO 'icingaweb'@'localhost' IDENTIFIED BY 'icinga123';
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icingawebdb.*TO 'icingaweb'@'localhost' IDENTIFIED BY 'icinga123';
After creating the database, we can install the Web interface plugin and configure it one by one. Apache2 and other web packages along with PHP modules gets installed along with this plugin.
root@ubuntu:~# apt-get install icingaweb2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
apache2 apache2-bin apache2-data apache2-utils fontconfig-config fonts-dejavu fonts-dejavu-core fonts-dejavu-extra icingaweb2-module-doc
icingaweb2-module-monitoring libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libfontconfig1 libfreetype6 libgd3 libjbig0
libjpeg-turbo8 libjpeg8 liblua5.1-0 libtiff5 libvpx3 libxpm4 libzend-framework-php php php-common php-dompdf php-font-lib php-gd
Once this is installed, we can call this URL in browser to "http://IP//icingaweb2/setup".
Configuring Icinga Web2 plugin
Our next step is to configure web interface. Please navigate through the screenshots to get more clarity on that.
Step 1 : Creating the token.
The initial setup page come up with a message to authenticate our Icingaweb user and create a token to proceed with the configuration.
To run this wizard a user needs to authenticate using a token which is usually provided to him by an administrator who'd followed the instructions below.
In any case, make sure that all of the following applies to your environment:
A system group called "icingaweb2" exists
The user "www-data" is a member of the system group "icingaweb2"addgroup --system icingaweb2; usermod -a -G icingaweb2 www-data;
If you've got the IcingaCLI installed you can do the following:
icingacli setup config directory --group icingaweb2; icingacli setup token create;In case the IcingaCLI is missing you can create the token manually:
su www-data -c "mkdir -m 2770 /etc/icingaweb2; chgrp icingaweb2 /etc/icingaweb2; head -c 12 /dev/urandom | base64 | tee /etc/icingaweb2/setup.token; chmod 0660 /etc/icingaweb2/setup.token;";Please see the Icinga Web 2 documentation for an extensive description on how to access and use this wizard.
We can just follow these instructions and provide the token key generated to the "Setup Token" column. This is how I did it.
root@ubuntu:/usr/local/src# addgroup --system icingaweb2
addgroup: The group `icingaweb2' already exists as a system group. Exiting.
root@ubuntu:/usr/local/src# usermod -a -G icingaweb2 www-dataroot@ubuntu:/usr/local/src# icingacli setup config directory --group icingaweb2;
Successfully created configuration directory /etc/icingaweb2
root@ubuntu:/usr/local/src# icingacli setup token create;
The newly generated setup token is: 1951e1eb11110e65
By providing the token, it will proceed to the next step.
Step 2 : Selecting the Modules.
After providing the token, it'll move to the next section for selecting the modules. We can choose the preferred modules to proceed to the next step.
Step 3 : Verifying the PHP settings.
To proceed further, we need to install the missing PHP modules and set proper timezone. You can install the required modules using the commands below:
#apt-get install php5.6-gd php5.6-json php5.6-dba php5.6-intl php5.6-ldap php5.6-pdo-mysql php5.6-imagick php5.6-dom
Furthermore, you can set a proper time zone in the PHP configuration file.
After meeting the required settings, you can proceed with the next stage.
Step 5 : Authenticating Methods
We need to choose the preferred authentication means to proceed with the installation. As I discussed before, I preferred to choose database type for this.
Step 6 : Fill out the database details which is used for authentication.
We need to enter the database details which we created for the web interface here. We can either create this prior to the setup or during this step from CLI. We need to make sure to provide this user, sufficient privileges over this database.
Step 7 : Creating Icinga Web administration users to manage the interface.
After authenticating our database resources successfully, we need to create the Administrative account for managing the Icinga2 Web interface. Please provide the preferred username and password to manage the interface.
Step 8 : Choosing the Application configuration options.
Next is to set the application configuration according to our needs. And proceed to the next stage.
Step 9 : Reviewing all chosen settings.
These stage will brief you with all the settings which you've done until now. We can confirm the settings and proceed further.
Step 10 : Configuring Monitoring Module.
Now we've completed with the authentication part and it follows with the configuration of the monitoring module.
As we discussed before, Icinga IDO module exports all status information and configuration parts to the Icinga main database. Hence, we need to select this module and configure it properly to update the database with the information.
Here we need to provide the main database information to proceed. Fill out the database details here. Make sure to set proper privileges for the database user for any modifications.
This choose the transport medium for monitoring instance.
We don't need to make any modification in this step. Just proceed with clicking 'Next".
Step 11 : Reviewing the Monitoring module configuration options
This stage will brief you with all the monitoring module configuration part which you've selected. You can just confirm the settings and proceed further to complete the setup.
Final Step : Login to the Web interface.
Now we can continue to login to the Icinga Web 2 interface with the login credentials created during the setup.
Our master node is added by default to this system. We can see the service notifications for our master Icinga server over here. Or you can just browse this URL http://IP/icingaweb2/ to access the web interface.
We can add any number of nodes to this system for monitoring. In my next article, I will provide you guidelines on how to add host nodes to our Icinga2 master server. I hope you enjoyed reading this article. I would recommend your valuable comments and suggestions on this.
The post How to Install Icinga2 on Ubuntu 16.04 appeared first on LinOxide.