ManagedCloud Servers

High performance handled and monitored by us 24/7/365. A complete solution to provide you with our in house expertise 24/7 tailored to your specific needs. We'll setup a bespoke server for your site using the latest tehnologies so you can get the most out of your hardware and get your website loading quickly and reliably. Find out more..

cPanelCloud Servers

Recommended - High performance cloud servers with no technical knowledge required. If you're hosting multiple websites already and you're looking to consolidate, or if you're looking to isolate yourself from the shared hosting environment but you don't have the time or knoweldge to manage a server, then the Managed cPanel Servers are for you. Find out more..

UnmanagedCloud Servers

Our unmanaged range gives you complete control at rock bottom prices and our cloud platform boasts super fast multipath 40Gb/s network, the latest Intel Xeon V3 CPUs and enterprise grade redundant SSDs. If you're a sysadmin look no further, we offer some of the best specification to price ratio servers available. Find out more..

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

View Plans

How to Install and Configure Icinga 2 on Ubuntu 16.04

Icinga 2 is an open source system monitoring tool that is used to check the availability of your network resources, services and generates performance data for reporting.

Icinga 2 also provides a user friendly web interface with more options to manage all systems. You can can monitor large, complex environments across multiple locations using Icinga 2.

Icinga 2 features:

  1. Used to monitor network services such as HTTP, POP3, SMTP, ping, etc.
  2. Used to monitor host resources such as disk usage, CPU load, etc.
  3. Used to monitor switches, routers and temperature.
  4. Provides wide range of plugins that allows users to easily develop their own service checks,
  5. Provides user friendly interface (Icinga Classic UI and Icinga Web) for checking host and service status, reports, logs, etc.
  6. Provides various add-ons such as PNP4Nagios, NagiosGrapher and InGraph to display statistics in graph.

In this tutorial, we will explain how to install and configure Icinga 2 and Icinga 2 Web on your Ubuntu-16.04 server.

Requirements

  • A server running Ubuntu-16.04.
  • A non-root user with sudo privileges setup on your server.

Installing Icinga 2

Before starting, make sure your system is up-to-date, you can do this by running the following command:

sudo apt-get update -y sudo apt-get upgrade -y

Once your system is updated, you will need to add icinga repository to apt.

First, add the icinga repository with the following command:

sudo add-apt-repository ppa:formorer/icinga

Output:

     This PPA provides Icinga 1, Icinga 2 and Icinga web Packages for Ubuntu. They are directly derived from the Debian Packages that I maintain within Debian.
     More info: https://launchpad.net/~formorer/+archive/ubuntu/icinga
    Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keyring `/tmp/tmpwiwlbofo/secring.gpg' created gpg: keyring `/tmp/tmpwiwlbofo/pubring.gpg' created gpg: requesting key 36862847 from hkp server keyserver.ubuntu.com gpg: /tmp/tmpwiwlbofo/trustdb.gpg: trustdb created gpg: key 36862847: public key "Launchpad PPA for Alexander Wirt" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1) OK

Then, update the apt repository using the following command:

sudo apt-get update -y

Now, install icinga2 by running the following command:

sudo apt-get install icinga2

Output:

    Creating config file /etc/nagios-plugins/config/apt.cfg with new version

Creating config file /etc/nagios-plugins/config/dhcp.cfg with new version

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/mail.cfg with new version

Creating config file /etc/nagios-plugins/config/news.cfg with new version

Creating config file /etc/nagios-plugins/config/ntp.cfg with new version

Creating config file /etc/nagios-plugins/config/ping.cfg with new version

Creating config file /etc/nagios-plugins/config/procs.cfg with new version

Creating config file /etc/nagios-plugins/config/real.cfg with new version

Creating config file /etc/nagios-plugins/config/ssh.cfg with new version

Creating config file /etc/nagios-plugins/config/tcp_udp.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 Setting up icinga2-common (2.5.4-1~ppa1~trusty2) ... Adding system-user for nagios * checking Icinga2 configuration [ OK ] * Starting icinga2 monitoring daemon icinga2 [2016-10-24 11:38:08 +0530] information/cli: Icinga application loader (version: r2.5.4-1) [2016-10-24 11:38:08 +0530] information/cli: Loading configuration file(s). [2016-10-24 11:38:08 +0530] information/ConfigItem: Committing config item(s). [2016-10-24 11:38:08 +0530] warning/ApplyRule: Apply rule 'satellite-host' (in /etc/icinga2/conf.d/satellite.conf: 29:1-29:41) for type 'Dependency' does not match anywhere! [2016-10-24 11:38:08 +0530] information/ConfigItem: Instantiated 1 Zone. [2016-10-24 11:38:08 +0530] information/ConfigItem: Instantiated 1 Endpoint. [2016-10-24 11:38:08 +0530] information/ConfigItem: Instantiated 2 NotificationCommands. [2016-10-24 11:38:08 +0530] information/ConfigItem: Instantiated 13 Notifications. [2016-10-24 11:38:08 +0530] information/ConfigItem: Instantiated 197 CheckCommands. [2016-10-24 11:38:08 +0530] information/ConfigItem: Instantiated 1 Host. [2016-10-24 11:38:08 +0530] information/ConfigItem: Instantiated 1 IcingaApplication. [2016-10-24 11:38:08 +0530] information/ConfigItem: Instantiated 2 HostGroups. [2016-10-24 11:38:08 +0530] information/ConfigItem: Instantiated 1 UserGroup. [2016-10-24 11:38:08 +0530] information/ConfigItem: Instantiated 1 User. [2016-10-24 11:38:08 +0530] information/ConfigItem: Instantiated 12 Services. [2016-10-24 11:38:08 +0530] information/ConfigItem: Instantiated 3 TimePeriods. [2016-10-24 11:38:08 +0530] information/ConfigItem: Instantiated 3 ServiceGroups. [2016-10-24 11:38:08 +0530] information/ConfigItem: Instantiated 1 ScheduledDowntime. [2016-10-24 11:38:08 +0530] information/ScriptGlobal: Dumping variables to file '/var/cache/icinga2/icinga2.vars' [2016-10-24 11:38:08 +0530] information/ConfigItem: Triggering Start signal for config items [2016-10-24 11:38:08 +0530] information/ConfigItem: Activated all objects. [ OK ] Setting up libicinga2 (2.5.4-1~ppa1~trusty2) ... Setting up icinga2-doc (2.5.4-1~ppa1~trusty2) ... Processing triggers for ureadahead (0.100.0-16) ... Setting up icinga2-bin (2.5.4-1~ppa1~trusty2) ... enabling default icinga2 features Enabling feature checker. Make sure to restart Icinga 2 for these changes to take effect. Enabling feature notification. Make sure to restart Icinga 2 for these changes to take effect. Enabling feature mainlog. Make sure to restart Icinga 2 for these changes to take effect. Setting up icinga2 (2.5.4-1~ppa1~trusty2) ... Processing triggers for libc-bin (2.19-0ubuntu6.3) ...

Once installation is complete, start icinga 2 service by running the following command:

sudo systemctl start icinga2.service

Output:

     * checking Icinga2 configuration                                                                                                             [ OK ] 
     * Restarting icinga2 monitoring daemon icinga2                                                                                                      [2016-10-24 11:44:12 +0530] information/cli: Icinga application loader (version: r2.5.4-1)
    [2016-10-24 11:44:12 +0530] information/cli: Loading configuration file(s).
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Committing config item(s).
    [2016-10-24 11:44:12 +0530] warning/ApplyRule: Apply rule 'satellite-host' (in /etc/icinga2/conf.d/satellite.conf: 29:1-29:41) for type 'Dependency' does not match anywhere!
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 1 Zone.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 1 FileLogger.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 1 Endpoint.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 2 NotificationCommands.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 13 Notifications.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 197 CheckCommands.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 1 Downtime.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 1 Host.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 1 IcingaApplication.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 2 HostGroups.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 1 UserGroup.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 1 User.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 12 Services.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 3 TimePeriods.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 3 ServiceGroups.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 1 ScheduledDowntime.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 1 CheckerComponent.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Instantiated 1 NotificationComponent.
    [2016-10-24 11:44:12 +0530] information/ScriptGlobal: Dumping variables to file '/var/cache/icinga2/icinga2.vars'
    [2016-10-24 11:44:12 +0530] information/ConfigObject: Restoring program state from file '/var/lib/icinga2/icinga2.state'
    [2016-10-24 11:44:12 +0530] information/ConfigObject: Restored 243 objects. Loaded 0 new objects without state.
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Triggering Start signal for config items
    [2016-10-24 11:44:12 +0530] information/ConfigItem: Activated all objects.

Next, enable icinga 2 service to start at boot with the following command:

sudo systemctl enable icinga2.service

Next, install icinga 2 plugins like nagios-plugins with the following command:

sudo apt-get install nagios-plugins

Output:

    Setting up nagios-plugins-standard (1.5-3ubuntu1) ...

Creating config file /etc/nagios-plugins/config/breeze.cfg with new version

Creating config file /etc/nagios-plugins/config/disk-smb.cfg with new version

Creating config file /etc/nagios-plugins/config/dns.cfg with new version

Creating config file /etc/nagios-plugins/config/flexlm.cfg with new version

Creating config file /etc/nagios-plugins/config/fping.cfg with new version

Creating config file /etc/nagios-plugins/config/games.cfg with new version

Creating config file /etc/nagios-plugins/config/hppjd.cfg with new version

Creating config file /etc/nagios-plugins/config/ifstatus.cfg with new version

Creating config file /etc/nagios-plugins/config/ldap.cfg with new version

Creating config file /etc/nagios-plugins/config/mailq.cfg with new version

Creating config file /etc/nagios-plugins/config/mrtg.cfg with new version

Creating config file /etc/nagios-plugins/config/mysql.cfg with new version

Creating config file /etc/nagios-plugins/config/netware.cfg with new version

Creating config file /etc/nagios-plugins/config/nt.cfg with new version

Creating config file /etc/nagios-plugins/config/pgsql.cfg with new version

Creating config file /etc/nagios-plugins/config/radius.cfg with new version

Creating config file /etc/nagios-plugins/config/rpc-nfs.cfg with new version

Creating config file /etc/nagios-plugins/config/snmp.cfg with new version Setting up nagios-plugins (1.5-3ubuntu1) ... Setting up perl-modules (5.18.2-2ubuntu1.1) ... Setting up perl (5.18.2-2ubuntu1.1) ... Setting up libnet-snmp-perl (6.0.1-2) ... Processing triggers for libc-bin (2.19-0ubuntu6.3) ... Processing triggers for ureadahead (0.100.0-16) ...

Installing MariaDB and Icinga 2 IDO Module

Next, you will also need to install MariaDB as the external database and IDO module which is used for Icinga2 web interface.

First, install MariaDB with the following command:

sudo apt-get install mariadb-client mariadb-server -y

Next, start the MariaDB service and enable it to start at boot with the following command:

sudo systemctl start mysql.service sudo systemctl enable mysql.service

By default, MariaDB installation is not secure, so you will need to secure it first.

You can secure MariaDB installation with the following command:

sudo mysql_secure_installation

Answer all the questions as shown below:

    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here.

Enter current password for root (enter for none): OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n ... skipping.

By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.

Remove anonymous users? [Y/n] Y ... Success!

Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y ... Success!

By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.

Remove test database and access to it? [Y/n] Y - Dropping test database... ... Success! - Removing privileges on test database... ... Success!

Reloading the privilege tables will ensure that all changes made so far will take effect immediately.

Reload privilege tables now? [Y/n] Y ... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB installation should now be secure.

Thanks for using MariaDB!

Once MariaDB is installed and secure, install IDO module with the following command:

sudo apt-get install icinga2-ido-mysql

In the configuration wizard, answer all the questions with no:

    Get:1 http://ppa.launchpad.net/formorer/icinga/ubuntu/ trusty/main icinga2-ido-mysql amd64 2.5.4-1~ppa1~trusty2 [127 kB]
    Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main dbconfig-common all 1.8.47+nmu1 [468 kB]
    Fetched 595 kB in 3s (178 kB/s)                                                
    Preconfiguring packages ...
    Selecting previously unselected package dbconfig-common.
    (Reading database ... 60045 files and directories currently installed.)
    Preparing to unpack .../dbconfig-common_1.8.47+nmu1_all.deb ...
    Unpacking dbconfig-common (1.8.47+nmu1) ...
    Selecting previously unselected package icinga2-ido-mysql.
    Preparing to unpack .../icinga2-ido-mysql_2.5.4-1~ppa1~trusty2_amd64.deb ...
    Unpacking icinga2-ido-mysql (2.5.4-1~ppa1~trusty2) ...
    Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
    Setting up dbconfig-common (1.8.47+nmu1) ...

Creating config file /etc/dbconfig-common/config with new version Setting up icinga2-ido-mysql (2.5.4-1~ppa1~trusty2) ... dbconfig-common: writing config to /etc/dbconfig-common/icinga2-ido-mysql.conf

Creating config file /etc/dbconfig-common/icinga2-ido-mysql.conf with new version

Creating config file /etc/icinga2/features-available/ido-mysql.conf with new version granting access to database icinga2 for icinga2@localhost: success. verifying access for icinga2@localhost: success. creating database icinga2: success. verifying database icinga2 exists: success. populating database via sql... done. dbconfig-common: flushing administrative password

Next, you will need to enable ido-mysql feature. You can enable it with the following command:

sudo icinga2 feature enable ido-mysql

Output:

    Enabling feature ido-mysql. Make sure to restart Icinga 2 for these changes to take effect.

Next, restart icinga 2 for these changes to take effect:

sudo systemctl restart icinga2.service

Once IDO module is installed, you will need to create database for icinga 2.

First, login to Mysql cell with the following command:

mysql -u root -p

Enter the password for root user, you should see the following output:

    Welcome to the MariaDB monitor.  Commands end with ; or g.
    Your MariaDB connection id is 52
    Server version: 5.5.52-MariaDB-1ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]>

Next, create a database named icinga2 with the username icinga2 and password icinga2:

MariaDB [(none)]> Create database icinga2;
    Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga2.*TO 'icinga2'@'localhost' IDENTIFIED BY 'icinga2';

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

Next, import the icinga 2 IDO schema with the following command:

mysql -u root -p icinga2 < /usr/share/icinga2-ido-mysql/schema/mysql.sql

Installing Icinga Web 2

You can install Icinga Web 2 package with the following command:

sudo apt-get install icingaweb2

Output:

    Selecting previously unselected package icingaweb2.
    (Reading database ... 62569 files and directories currently installed.)
    Preparing to unpack .../icingaweb2_2.3.4+fix-1~ppa1604+1_all.deb ...
    Unpacking icingaweb2 (2.3.4+fix-1~ppa1604+1) ...
    Selecting previously unselected package icingaweb2-module-doc.
    Preparing to unpack .../icingaweb2-module-doc_2.3.4+fix-1~ppa1604+1_all.deb ...
    Unpacking icingaweb2-module-doc (2.3.4+fix-1~ppa1604+1) ...
    Selecting previously unselected package icingaweb2-module-monitoring.
    Preparing to unpack .../icingaweb2-module-monitoring_2.3.4+fix-1~ppa1604+1_all.deb ...
    Unpacking icingaweb2-module-monitoring (2.3.4+fix-1~ppa1604+1) ...
    Setting up icingaweb2 (2.3.4+fix-1~ppa1604+1) ...
    apache2_invoke rewrite: already enabled
     * Restarting web server apache2                                                                                                                     AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
                                                                                                                                                  [ OK ]
    apache2_invoke: Enable configuration icingaweb2
     * Reloading web server apache2                                                                                                                       * 
    Setting up icingaweb2-module-doc (2.3.4+fix-1~ppa1604+1) ...
    Setting up icingaweb2-module-monitoring (2.3.4+fix-1~ppa1604+1) ...

You will allso need to install some PHP version PHP5 and other PHP modules in order to access Icinga 2 Web.

For installing PHP5, you will need to enable a "ondrej/php repository.

You can add this repo with the following command:

sudo add-apt-repository ppa:ondrej/php

Next, install PHP with all other modules with the following command:

sudo apt-get install php5 php5-gd php5-json php5-intl php5-ldap php5-imagick php5-pgsql

Once installation is complete, you will need to define timezone in php.ini file:

sudo /etc/php5/apache2/php.ini

Add the following line:

    date.timezone = Asia/Calcutta

Next, it's time to access Icinga 2 Web interface.

Before accessing Web interface, you will also need to generate a setup token.

You can generate it with the following command:

sudo icingacli setup token create

Output:

    The newly generated setup token is: bfd39f36b9437402

Once token is generated, Open your favorite web browser and type the URL http://your-server-ip/icingaweb2/setup and hit enter, you should see the following page:

Now, enter the token which you have generated earlier and click on Next, you should see the following page:

Next, select the module and click on Next, you should see the following page:

On the Authentication page, choose Database and click Next.

On the Database Resource page, fill out all the required fields and click on Next button.

On the Authentication Backend page, select the default backend name icingaweb2 and click on `Next, button.

On the Administration page, create your first administrative account with username icingawebadmin and password admin@123, then click on the Next button.

On the Application Configuration page, change the settings as per your need and click on the Next button.

On the Review page, check your configuration and click on the Next button.

On the Monitoring Module Configuration Welcome page, and click on the Next button.

On the Monitoring Backend page, use the default backend name icinga and backend type IDO and click on the Next button.

On the Monitoring IDO Resource page, fill out all the details you setup earlier and click on the Next button.

On the Command Transport page, use the default settings and click on the Next button.

On the Monitoring Security page, use the defaults value and click on the Next button.

On the review page, double check your configuration and click on the Finish button.

On the Congratulations! page, click the Login to Icinga Web 2 button to jump to the Icinga Web 2 login page, enter your Icinga Web 2 administrative account and password you setup earlier to log in Icinga Web 2 dashboard, you should see the following page:

Conclusion

Finally! you have successfully installed Icinga 2 and Icinga 2 Web on your server. You can now easily monitor different services and host machines using the Icinga 2 Web interface.

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

View Plans