How to Install Icinga 2 on Ubuntu 18.04

In this tutorial, you will learn how to install Icinga 2 and Icinga Web 2 and all their necessary components on an Ubuntu 18.04 Cloud VPS.

Icinga 2 is a free and open-source server monitoring system. It helps its users to check the availability of their network resources, notifies them about outages, and generates performance data which allows reports to be created.

Features:

  • Different types of logging: File logging, Syslog and Console logging
  • External command pipe for processing commands triggering specific actions
  • Performance data
  • Clear-cut, object-based configuration
  • Dynamic notifications
  • Elasticsearch Writer

Prerequisites:

  • VPS with Ubuntu 18.04 OS template
  • System user with root privileges

Step 1. Log in to your server via SSH

In order to start with the installation, we have to login to the Ubuntu 18.04 VPS via SSH as user root

ssh root@<span style="color: #ff0000;">IP_Address</span> -p <span style="color: #ff0000;">Port_number</span>

where IP_Address and Port_number are the actual IP address and SSH port number of your server.

Step 2. Update theServer

Once you are logged in, run the following command to make sure that all installed packages are updated to the latest available version:

apt update && apt upgrade

Step 3. Install Icinga 2

The preferred way of installing Icinga 2 is by using their official package repositories for the appropriate operating system. In our case we will use the repositories for Ubuntu. By installing Icinga using this method, we will always have the latest available version of Icinga 2 maintained by their team.

First, we’ll need to install CURL and the API transport packages, which are necessary for downloading files via the HTTP Secure protocol:

apt install -y apt-transport-https curl

Next, add the Icinga 2 public signing key and official repository to your server.

wget -O - https://packages.icinga.com/icinga.key | apt-key add -

DIST=$(awk -F"[)(]+" '/VERSION=/ {print $2}' /etc/os-release); \
 echo "deb https://packages.icinga.com/raspbian icinga-${DIST} main" > \
 /etc/apt/sources.list.d/icinga.list
 echo "deb-src https://packages.icinga.com/raspbian icinga-${DIST} main" >> \
 /etc/apt/sources.list.d/icinga.list

Update the repositories list again:

apt update

We can now install Icinga 2 using the apt package manager:

apt -y install icinga2

Once the installation is complete, you can issue the following command to check the Icinga 2 version, currently it is version r2.10.4-1 (at the time of writing this tutorial). Additionally, we get several other useful types of information about the monitoring tool and the server configuration:

icinga2 --version

Output:

icinga2 - The Icinga 2 network monitoring daemon (version: r2.10.4-1)

Copyright (c) 2012-2019 Icinga GmbH (https://icinga.com/)
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl2.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

System information:
  Platform: Ubuntu
  Platform version: 18.04.2 LTS (Bionic Beaver)
  Kernel: Linux
  Kernel version: 4.15.0-39-generic
  Architecture: x86_64

Here are the commands for Systemd to start Icinga 2 as well as enable the service to automatically start on server boot:

systemctl start icinga2
systemctl enable icinga2

To make sure that the service is up and running, check its status using the following command:

systemctl status icinga2

Output:

icinga2.service - Icinga host/service/network monitoring system
   Loaded: loaded (/lib/systemd/system/icinga2.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/icinga2.service.d
           ââlimits.conf
   Active: active (running) since Sun 2019-05-12 04:05:06 CDT; 31min ago
 Main PID: 31825 (icinga2)
    Tasks: 8
   CGroup: /system.slice/icinga2.service
           ââ31825 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e /var/log/icinga2/error.log
           ââ31859 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e /var/log/icinga2/error.log

Icinga 2 collects information about the services based on monitoring plugins. Without these plugins, Icinga 2 does not know how to check the services. For this purpose we will use the Monitoring Plugins Project. They maintain a collection of monitoring plugins including plugins for Icinga 2. To install the monitoring-tools package, run the following command:

apt -y install monitoring-plugins

The initial installation of Icinga 2 has three features enabled by default: checker, notification, and mainlog. You can check all enabled and disabled features using the following command:

icinga2 feature list
Disabled features: api command compatlog debuglog elasticsearch gelf graphite influxdb livestatus opentsdb perfdata statusdata syslog
Enabled features: checker mainlog notification

Step 4. Install IDO Modules for MySQL

In order to configure Icinga 2 to be able to use MySQL, we’ll have to install IDO modules. It can be easily done using Ubuntu’s default package manager:

apt install icinga2-ido-mysql

During the installation, you will be prompted to enter a password for the Icinga 2 MySQL user and whether you would like the database to be configured.

Once the installation is finished, enable the IDO MySQL module:

icinga2 feature enable ido-mysql

Restart Icinga 2 for the changes to take effect:

systemctl restart icinga2.service

Step 5. Install Icinga Web 2

In order to be able to monitor the server and check statistics through a web browser, we will install Icinga Web 2. It is a powerful PHP framework with a clean and user-friendly design. It can be easily installed from the official Icinga 2 repository that we already added to the server. Please note that Icinga Web 2 requires a LAMP stack installed on the server prior to installing this web package.

apt install icingaweb2 libapache2-mod-php icingacli

Icinga Web 2 can be configured through the Icinga Web 2 setup wizard, which can be accessed using your preferred web browser. When using the web setup wizard, you are required to authenticate using a token. To generate a token, run the following command:

icingacli setup token create
The newly generated setup token is: 64b889fd4e6830a5

Now, navigate to http://IP_Address/icingaweb2/setup to start the web setup wizard and complete the installation. The setup will run only if your server meets the requirements. Don’t forget to use the token you got earlier for the setup process.

 

That’s it! You have successfully installed Icinga 2 on your Ubuntu 18.04 server. For detailed instructions on how to configure and use Icinga 2, please check their official documentation.


Of course, you don’t have to install Icinga 2 on Ubuntu 18.04 if you use one of our Managed Cloud VPS services, in which case you can simply ask our expert Linux admins to install and configure Icinga 2 on your Ubuntu 18.04 server for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post on how to install Icinga 2 on Ubuntu 18.04, or if you found it helpful, please share it with your friends on the social networks using the social media share shortcuts, or simply leave a reply below. Thank you.

Leave a Comment