Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
04 | DigitalOcean
Community Menu
Introduction
Icinga is a flexible and powerful open-source monitoring system used to oversee the health of networked hosts and services. It could be used to
monitor the load and uptime of a cluster of web workers, free disk space on a storage device, memory consumption on a caching service, and so
on. Once properly set up, Icinga can give you an at-a-glance overview of the status of large numbers of hosts and services, as well as notifications,
downtime scheduling, and long-term storage of performance data.
This tutorial will cover installing the Icinga core, its database backend, and the Icinga Web interface. Finally, we'll set up email notification so you can
receive alerts in your inbox when a service is misbehaving.
Prerequisites
Before starting this tutorial you will need:
An Ubuntu 16.04 server with the LAMP stack installed, which is detailed in our tutorial How To Install Linux, Apache, MySQL, PHP (LAMP) stack on
Ubuntu 16.04.
Because Icinga Web has a login page and also asks you to input sensitive information during setup, you should enable SSL encryption for
Apache. You can learn how to fetch and install free SSL certificates in our tutorial How To Secure Apache with Let's Encrypt on Ubuntu 16.04.
First, download the Icinga developers' package signing key and add it to the apt system:
This key will be used to automatically verify the integrity of any software we download from the Icinga repository. Now we need to add the
repository address to an apt configuration file. Open up the file with your favorite text editor. We'll use nano throughout this tutorial:
This will open a new blank text file. Paste in the following line:
/etc/apt/sources.list.d/icinga.list
Save and close the file, then refresh your package cache:
apt-get will now download information from the repository we just added, making the Icinga packages available to install:
S C R O L L TO TO P
https://www.digitalocean.com/community/tutorials/how-to-install-icinga-and-icinga-web-on-ubuntu-16-04 1/9
7/7/2017 How To Install Icinga and Icinga Web on Ubuntu 16.04 | DigitalOcean
This will install the main Icinga software, along with a database adapter that enables Icinga to put historical data and other information into a MySQL
database. You'll be presented with a few configuration screens for the database adapter:
3. You'll then be prompted to set up an Icinga database password. Create a strong password and record it for later. We'll need it when setting up the
web interface.
Now we need to actually enable the Icinga database backend. The icinga2 command can enable and disable features on the command line. While
we're at it, we'll also enable the command feature which will eventually let us run manual health checks from the web interface.
And finally, let's check the status of icinga2 to make sure it's running properly:
Output
icinga2.service - Icinga host/service/network monitoring system
Loaded: loaded (/lib/systemd/system/icinga2.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2017-04-20 00:54:55 UTC; 3s ago
Process: 15354 ExecStartPre=/usr/lib/icinga2/prepare-dirs /usr/lib/icinga2/icinga2 (code=exited, status=0/SUCCESS)
Main PID: 15416 (icinga2)
Tasks: 11
Memory: 7.7M
CPU: 488ms
. . .
If you see Active: active (running) , Icinga is up and running. Now that we've set up the Icinga core system and database backend, it's time to
get the web interface up and running.
The rest of Icinga Web's setup is done in a web browser, but before we switch over, there's one setting we need to update. Icinga Web needs a
timezone to be set for the PHP environment, so let's edit the PHP config file:
We need to find a specific line to update. In nano we can press CTRL-W to bring up a search interface, type in date.timezone , then hit ENTER . The
cursor will move to the line we need to update. First, uncomment the line by removing the initial ; semicolon, and then type in your correct
timezone.
You can find the correct timezone format in the PHP manual's timezone section. It should look something like this when you're finished:
/etc/php/7.0/apache2/php.ini
S C R O L L TO TO P
date.timezone = America/New_York
https://www.digitalocean.com/community/tutorials/how-to-install-icinga-and-icinga-web-on-ubuntu-16-04 2/9
7/7/2017 How To Install Icinga and Icinga Web on Ubuntu 16.04 | DigitalOcean
Output
1558c2c0ec4572ab
Copy the token to your clipboard, then switch to your browser and load the Icinga Web address. By default this is your servers domain name or IP
address followed by /icingaweb2 :
https://icinga-master.example.com/icingaweb2
You'll be presented with a configuration screen. Paste in the token you copied to your clipboard, and press Next to begin the process. There are
many pages of options to go through. We'll step through them one at a time.
Module Setup
On the second page, you'll have the option to enable some extra modules for the web interface. We can safely accept the default of only enabling
the Monitoring module. Click Next to continue.
Environment Status
The third page shows the status of our PHP environment. You shouldn't see any red boxes, which would indicate an issue or misconfiguration. You
may see some yellow boxes mentioning PostgreSQL modules being missing. We can safely ignore these, as we're using MySQL, not PostgreSQL.
S C R O L L TO TO P
Click Next to continue.
https://www.digitalocean.com/community/tutorials/how-to-install-icinga-and-icinga-web-on-ubuntu-16-04 3/9
7/7/2017 How To Install Icinga and Icinga Web on Ubuntu 16.04 | DigitalOcean
Most of the defaults are fine, but we also need to choose a database name and user/password combination:
3. Host: localhost
4. Port:
6. Username: icingaweb
8. Character Set:
Configuration Review
We are presented with a page to review all of our configurations. Click Next to confirm the configuration details and move on to configuring the
monitoring module.
https://www.digitalocean.com/community/tutorials/how-to-install-icinga-and-icinga-web-on-ubuntu-16-04 4/9
7/7/2017 How To Install Icinga and Icinga Web on Ubuntu 16.04 | DigitalOcean
This page has all the same options as the user-database setup screen:
3. Host: localhost
4. Port:
6. Username: icinga2
8. Character Set
9. Persistent: unchecked
Click Login to Icinga Web 2 and log in with your administrator username and password.
The main interface of Icinga Web will load. Explore a little and familiarize yourself with the interface. If your server has no swap space set up, you
may see a red Critical Error box. We can ignore this for now, or you can Acknowledge the issue by clicking the red box, selecting Acknowledge
from the right-hand column, filling out a comment, and finally clicking the Acknowledge problem button.
Now that we've finished setting up Icinga, and Icinga Web, let's set email notifications.
https://www.digitalocean.com/community/tutorials/how-to-install-icinga-and-icinga-web-on-ubuntu-16-04 5/9
7/7/2017 How To Install Icinga and Icinga Web on Ubuntu 16.04 | DigitalOcean
And now we edit the ssmtp configuration file with our SMTP details. These should be provided by your ISP, email provider, or IT department. You'll
need a username, pasword, and the address of your SMTP server:
There will be some existing configuration in the file. Delete it and replace it with this very basic setup that should work with most SMTP servers:
/etc/ssmtp/ssmtp.conf
mailhub=mail.example.com:465
UseTLS=yes
FromLineOverride=yes
AuthUser=smtp_username
AuthPass=smtp_password
Save and close the file. To test the connection, use the mail command:
You should see an email in your inbox shortly. Now we need to update a few settings for Icinga to send mail.
Change the email line to the address you'd like to receive notifications at:
/etc/icinga2/conf.d/users.conf
. . .
email = "sammy@example.com"
. . .
The icinga-master host is already configured to send notifications when problems arise. Let's cause a problem and see what happens. We'll use a
command called stress to increase the system's load in order to trigger a warning.
Install stress :
stress can manipulate load, disk IO, memory, and other system metrics. The Icinga default configuration will trigger a warning when the system's
load is over five. Let's cause that now:
$ stress --cpu 6
S C R O L L TO TO P
https://www.digitalocean.com/community/tutorials/how-to-install-icinga-and-icinga-web-on-ubuntu-16-04 6/9
7/7/2017 How To Install Icinga and Icinga Web on Ubuntu 16.04 | DigitalOcean
Switch back to the Icinga Web interface and you'll see the load metric slowly rise. After a few checks it will enter a soft Warning state. Soft means
that the check has to fail a few more times before it's considered a hard state, at which time notifications will be sent. This is to avoid sending
notifications for transient issues that quickly fix themselves.
Wait for the warning to reach a hard state and send the notification. You should receive an email with the details of what's going wrong.
Press CTRL-C to exit the stress command. The system load will recover fairly quickly and revert to Ok in the Icinga Web interface. You'll also
receive another email telling you that the issue has cleared up.
Conclusion
In this tutorial we have successfully set up Icinga and Icinga Web, including Icinga's email notification feature. Currently we are only monitoring the
Icinga host itself though. Continue on to our next tutorial How To Monitor Hosts and Services with Icinga on Ubuntu 16.04 where we will set up
remote monitoring.
LEARN MORE
Related Tutorials
An Introduction to Tracking Statistics with Graphite, StatsD, and CollectD
How To Install and Configure Monit
How To Monitor Zabbix Alerts with Alerta on Ubuntu 16.04
How to Install and Configure Zabbix to Securely Monitor Remote Servers on Ubuntu 16.04
How To Monitor Zabbix Alerts with Alerta on CentOS 7
1 Comment
Leave a comment...
Log In to Comment
Thank you! Everything worked (skipped email setup as I have postfix already setup). On my Ubuntu 16.04 I got red
0
https://www.digitalocean.com/community/tutorials/how-to-install-icinga-and-icinga-web-on-ubuntu-16-04 7/9
7/7/2017 How To Install Icinga and Icinga Web on Ubuntu 16.04 | DigitalOcean
0 DISK CRITICAL - /sys/kernel/debug/tracing is not accessible: Permission denied
warnings which turned out to be a triaged bug in actual version of icinga 2.1.0 (found information at https://bugs.launchpad.net/ubuntu/+source/nagios-
plugins/+bug/1516451).
I could solve my problem by modifying /etc/nagios-plugins/config/disk.cfg as shown there just adding the parts (including) -A .. to the check_disk and
check_all_disks command. Restarting icinga2 as shown above.
define command{
command_name check_disk
command_line /usr/lib/nagios/plugins/check_disk -w '$ARG1$' -c '$ARG2$' -e -p '$ARG3$' -A --exclude-type=tracefs --exclude-type
}
Copyright 2017 DigitalOcean Inc.
Distros & One-Click Apps Terms, Privacy, & Copyright Security Report a Bug Get Paid to Write Shop
S C R O L L TO TO P
https://www.digitalocean.com/community/tutorials/how-to-install-icinga-and-icinga-web-on-ubuntu-16-04 8/9
7/7/2017 How To Install Icinga and Icinga Web on Ubuntu 16.04 | DigitalOcean
https://www.digitalocean.com/community/tutorials/how-to-install-icinga-and-icinga-web-on-ubuntu-16-04 9/9