Install Icinga2 on Ubuntu 16.04: Difference between revisions

From ICO wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 35: Line 35:
==What is Icinga?==
==What is Icinga?==


==Installation==
----
Icinga is made of two parts - Icinga 2 and Icinga Web 2. The first one is the core of the software and the second is a web interface.
Icinga is made of two parts - Icinga 2 and Icinga Web 2. The first one is the core of the software and the second is a web interface.


===Install Icinga 2 core===
==Install Icinga 2 core==
Add Icinga's repository to the package management configuration.
Add Icinga's repository to the package management configuration.


Line 60: Line 60:
<code>$ systemctl enable icinga2.service</code>
<code>$ systemctl enable icinga2.service</code>


===Install plugins===
==Install plugins==
====Nagios plugins====
===Nagios plugins===
To be able to check external services, Icinga needs monitoring plugins to know about them and to make sure they work properly. Available monitoring plugins are available on the [https://www.monitoring-plugins.org Monitoring Plugins Project website].
To be able to check external services, Icinga needs monitoring plugins to know about them and to make sure they work properly. Available monitoring plugins are available on the [https://www.monitoring-plugins.org Monitoring Plugins Project website].
We install the main set of plugins that come from [https://www.nagios.org Nagios] monitoring solution. ''Note that Icinga service runs as user and group called "Nagios" (for historical reasons).''
We install the main set of plugins that come from [https://www.nagios.org Nagios] monitoring solution. ''Note that Icinga service runs as user and group called "Nagios" (for historical reasons).''
Line 67: Line 67:
<code>$ apt install nagios-plugins</code>
<code>$ apt install nagios-plugins</code>


====Vim and Nano configuration syntax highlighting====
===Vim and Nano configuration syntax highlighting===
Icinga provides packages to highlight its configuration files using Nano and Vim utilities. The package for Nano is included by default when installinIcinga2.
Icinga provides packages to highlight its configuration files using Nano and Vim utilities. The package for Nano is included by default when installinIcinga2.
For Vim, do:
For Vim, do:
Line 74: Line 74:
<code>$ vim-addon-manager -w install icinga2</code>
<code>$ vim-addon-manager -w install icinga2</code>


===Install and configure PostgreSQL databases===
==Install and configure PostgreSQL databases==
Icinga needs two databases to work: one main to store monitoring information and one to store all configuration and status information. The later is the DB IDO (Database Icinga Data Output) module.
Icinga needs two databases to work: one main to store monitoring information (DB IDO: Database Icinga Data Output) and one to store users and groups information for the web interface.
We will install both of them manually.


====Install PostgreSQL====
===Install PostgreSQL===
Install PostgreSQL database system.
Install PostgreSQL database system.


<code>$ apt install postgresql</code>
<code>$ apt install postgresql</code>


====Install IDO module for PostgreSQL====
===Install IDO module for PostgreSQL===
The IDO module will create the IDO database for us, but it is possible to do it manually as well.
 
Install Icinga IDO module for PostgreSQL.
Install Icinga IDO module for PostgreSQL.
It installs files and directories to enable the export and storage of monitoring information into a database.
We will install the database manually in our tutorial.


<code>$ apt install icinga2-ido-pgsql</code>
<code>$ apt install icinga2-ido-pgsql</code>


A wizard will start. Say "yes" to confirm to enable the IDO module for PostgreSql.
A wizard will start.  
Say "No" to enable the IDO module for PostgreSQL, we do it manually later.
The wizard proposes us to create and configure the database for us. Choose “No” because we will do it manually (see below).
 
===Create IDO database===
Create the main database for Icinga.
First go to the /tmp directory because that is the default unix socket location for PostgreSQL.


The wizard proposes us to create and configure the database for us. Unless you know what you are doing, choose “Yes”. It will create the IDO database and ask you a password for it. ''Note: the default user and name of this database is "Icinga2".''
<code>$ cd /tmp</code>


====Create main PostgreSQL database====
Create a role (similar to a user) for the database. The database will require to login and we choose a password. You can choose a different role name ("icingaido") and a different password ("icingaidopass") than what is given as an example below. ''Remember them for later!''
Create the main database for Icinga.  
<code>$ sudo -u postgres psql -c "CREATE ROLE icingaido WITH LOGIN PASSWORD 'icingaidopass'"</code>
First go to the /tmp directory because that is the default unix socket location for PostgreSQL.


Create the database (“icingaidodb”) and we assign its owner as being “icingaido” (created earlier) with UTF8 encoding.
<code>$ sudo -u postgres createdb -O icingaido -E UTF8 icingaidodb</code>


<code>$ cd /tmp</code>
Edit the file ''/etc/icinga2/features-enabled/ido-mysql.conf'' and insert the values you have chosen for the IDO database.
<pre>
object IdoMysqlConnection "ido-mysql" {
  user = "icingaido",
  password = "icingaidopass",
  host = "localhost",
  database = "icinga"
}
</pre>

Revision as of 12:49, 12 November 2016

Author: Etienne Barrier

Last modified: 11.11.2016

Background

This tutorial shows how to install Icinga 2 on Ubuntu 16.04 LTS, using PostgreSQL (as for database) and Apache 2 (as for webserver).

This tutorial does NOT show: - how to install Icinga version 1 - how to install/configure databses other than PostgreSQP (for example MySQL, MariaDB, etc.) - how to install/configure webservers other than Apache2 (for example Nginx) - how to use Icinga2

It is assumed that you are already familiar with the basics of Linux command line terminal commands. But this tutorial is made so that you can copy paste the commands to your terminal.

Versions used in this tutorial: - Icinga 2 (version: r2.5.4-1) - Ubuntu 16.04.1 LTS (Xenial) - PostgreSQL (version: 9.5.2) - Apache 2 (version: 2.4.18) - Php (version 7.0)

Depending on the versions you use, the commands and/or the path shown in this tutorial might be different.

The version of Icinga used (version 2) is referred sometimes as “Icinga” or “Icinga 2” accross the tutorial.

This tutorial is based on the following tutorials: Official Icinga documentation [1] [2]

For any comments, please write to etienne(dot}barrier{at]itcollege[dot)ee.


What is Icinga?


Icinga is made of two parts - Icinga 2 and Icinga Web 2. The first one is the core of the software and the second is a web interface.

Install Icinga 2 core

Add Icinga's repository to the package management configuration.

$ add-apt-repository ppa:formorer/icinga $ apt update

Install Icinga 2 package.

$ apt install icinga2

Once done, check that Icinga is up and running

$ service icinga2 status

If it is not running, start it.

$ service icinga2 start

Make sure Icinga will start automatically on startup.

$ systemctl enable icinga2.service

Install plugins

Nagios plugins

To be able to check external services, Icinga needs monitoring plugins to know about them and to make sure they work properly. Available monitoring plugins are available on the Monitoring Plugins Project website. We install the main set of plugins that come from Nagios monitoring solution. Note that Icinga service runs as user and group called "Nagios" (for historical reasons).

$ apt install nagios-plugins

Vim and Nano configuration syntax highlighting

Icinga provides packages to highlight its configuration files using Nano and Vim utilities. The package for Nano is included by default when installinIcinga2. For Vim, do:

$ apt install vim-icinga2 vim-addon-manager $ vim-addon-manager -w install icinga2

Install and configure PostgreSQL databases

Icinga needs two databases to work: one main to store monitoring information (DB IDO: Database Icinga Data Output) and one to store users and groups information for the web interface. We will install both of them manually.

Install PostgreSQL

Install PostgreSQL database system.

$ apt install postgresql

Install IDO module for PostgreSQL

Install Icinga IDO module for PostgreSQL. It installs files and directories to enable the export and storage of monitoring information into a database. We will install the database manually in our tutorial.

$ apt install icinga2-ido-pgsql

A wizard will start. Say "No" to enable the IDO module for PostgreSQL, we do it manually later. The wizard proposes us to create and configure the database for us. Choose “No” because we will do it manually (see below).

Create IDO database

Create the main database for Icinga. First go to the /tmp directory because that is the default unix socket location for PostgreSQL.

$ cd /tmp

Create a role (similar to a user) for the database. The database will require to login and we choose a password. You can choose a different role name ("icingaido") and a different password ("icingaidopass") than what is given as an example below. Remember them for later! $ sudo -u postgres psql -c "CREATE ROLE icingaido WITH LOGIN PASSWORD 'icingaidopass'"

Create the database (“icingaidodb”) and we assign its owner as being “icingaido” (created earlier) with UTF8 encoding. $ sudo -u postgres createdb -O icingaido -E UTF8 icingaidodb

Edit the file /etc/icinga2/features-enabled/ido-mysql.conf and insert the values you have chosen for the IDO database.

object IdoMysqlConnection "ido-mysql" {
  user = "icingaido",
  password = "icingaidopass",
  host = "localhost",
  database = "icinga"
}