How to Add Hosts to Icinga2 using the Icinga Director

1 2

How to Add Hosts to Icinga2 using the Icinga Director

In this tutorial, we will show you how to add hosts to Icinga2 using a module called ‘Icinga Director’ and how to configure server and service monitoring.


For this guide, we will need Icinga2 installed on the system and the Icinga Director module has been enabled and configured correctly. For the Icinga2 installation, you can use this link.

What we will do?

  • Create Service Template
  • Create ServiceSet and Add Service Templates
  • Create a Host Template and Add ServiceSet
  • Add Hosts to Icinga2 Server
  • Client Host Initialization
  • Testing

Step 1 – Create Service Template

Firstly, we need to create templates that will be used to monitor our services and systems. So, we need to define which service and part of the system will be monitored by Icinga2.

For this guide, we will create some templates through the Icinga Director to monitor SSH, HTTP, APT check update, System Load, and Disk Usage.

Login to Icinga2 dashboard using your admin user and password, then Click the ‘Icinga Director‘ menu on the left.

Now click the ‘Services‘ and click the ‘Service Templates‘ option on the page. To create a new service template, click the ‘Add‘ button.

Add service template

Type details about your service details. Following is an example for monitoring the SSH service.

Service template details

Click the ‘Add‘ button and the service template for SSH has been created.

Now redo this step to create other services such as HTTP, APT check update, System Load, Disk usage.

Template list

Step 2 – Create a ServiceSet and Add Service Templates

After creating some service templates, we will make those templates as one ServiceSet.

On the ‘Services‘ page, click the ‘ServiceSet‘ and click ‘Add‘ button.

Create a ServiceSet

Now type the ‘Service set name’ and Description with your own, then click ‘Add‘ button again.

Details of Services Set

And the ServiceSet named ‘basic-services-ubuntu’ has been created.

Next, we will add our service templates to the ‘basic-services-ubuntu’ ServiceSet. Click on the ServiceSet name and click the ‘Services‘ tab on the right screen.

Created ServicesSet

Click the ‘Add Service‘ button.

Type the service templates name on the ‘Import‘ field and then click ‘Add‘ again.

Add service

And the service templates have been added to the ‘basic-services-ubuntu’ ServiceSet.

Now redo this step to add all service templates that we’ve created to the ‘basic-services-ubuntu’ ServiceSet.

Templates added

Step 3 – Create a Host Template and Add ServiceSet

In order to add new Hosts to Icinga2 through Director, we need to create the Host templates. And for this step, we will create the host template and add ServiceSet into it.

On the Icinga Director menu, click ‘Hosts’ and ‘Host Templates’.

Host templates

Now click the ‘Add‘ button.

Type details about the Hosts Templates such as below.

Add new Icinga Host template

Click ‘Add‘ button again and the Host Templates named ‘ubuntu-template’ has been created.

Next, we will add the ServiceSet named ‘basic-services-ubuntu’ to our host template.

Click the Host template name on the list, then click the ‘Service‘ tab on the right screen.

Now click the ‘Add Service Set‘ button.

Add Service Set

Choose the ServiceSet that we’ve created named ‘basic-services-ubuntu’ and click ‘Add‘.


As a result, the Host Template has been created with the ServiceSet added into it. And we’re ready to add new hosts to the Icinga2.

Step 4 – Add Host to Icinga2 Server

In this step, we will add new hosts to the Icinga2 Server. We will add the Ubuntu Server 18.04 with the hostname ‘client1.hakase-labs.io’, and the IP address ‘’.

On the Icinga2 Dashboard, click the ‘Icinga Director’ menu and click ‘Hosts‘.

Now Click ‘Hosts‘ on the page and click the ‘Add‘ button on the right screen.

Add Host

Choose the ‘basic-ubuntu‘ Host Template, and type detailed host configurations.

Add new Icinga Host

Now click the ‘Add‘ button.

Once all of these are complete, click the ‘Activity Log‘ menu on the left and click the ‘Deploy xx Pending Changes‘ to apply our setup.

Activity Log

And as a result, the ‘client1’ host has been added to the Icinga2 using the ‘basic-ubuntu’ host template that contains the ‘basic-service-ubuntu’ ServiceSet.

Step 5 – Client Host Initialization

In this step, we will initialize the ‘client1’ server by installing the Icinga2 packages into it and configuring the remote Agent into it.

Connect to the ‘client1’ server.
ssh root@client1

Edit the ‘/etc/hosts’ file using vim editor.

Add hosts configuration below.   icinga2.hakase-labs.io  icinga2   client1.hakase-labs.io  client1

Save and close.

Next, add the icinga2 key.
curl https://packages.icinga.com/icinga.key | apt-key add -

Then goto the ‘/etc/sources.list.d’ directory and create the ‘icinga2.list’ repository file.
cd /etc/apt/sources.list.d/
vim icinga2.list

Paste Icinga2 repository below.
deb http://packages.icinga.com/ubuntu icinga-bionic main
deb-src http://packages.icinga.com/ubuntu icinga-bionic main

Save and close.

Now update the repository and install Icinga2 packages using the apt command below.
sudo apt update
sudo apt install icinga2 monitoring-plugins

The Icinga2 packages have been installed on the ‘client1’ server.

Now back to the icinga2 dashboard, click the ‘Hosts‘ menu and click the ‘client1’ host on the list.

Now click the ‘Agent‘ tab of the client1 host configuration.

Initialize Client Host

Copy the Linux Script for the Agent deployment.

After that, back to the ‘client1’ server and create a new configuration called ‘deploy-agent.sh’.
vim deploy-agent.sh

Paste the agent deployment script into it.
DEPLOYMENT SCRIPT From the Icinga2 Dashboard

Save and close.

Make the script executable and run.
chmod +x deploy-agent.sh

And you will get the result as below.


Once it’s complete, restart the icinga2 service using the systemctl command below.
systemctl restart icinga2

And the initialization of Client Host server has been completed.

Step 6 – Testing

On the Icinga2 Dashboard menu, click ‘Overview‘ and ‘Hosts‘. Now you will be shown two hosts the icinga2 server and ‘client1’ is up and running.

Test Icinga

Click the ‘client1‘ server to see details.

Test Client 1

You will get a summary of the ‘client1’ server.

To get the monitored services for client1 hosts, click the ‘Services‘ tab.


Now you will get the service templates have been used on the ‘client1’ host.

And finally, we’ve successfully added the Linux Hosts to the Icinga2 Monitoring System through the Icinga Director module.


Đăng ký liền tay Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !

Add Comment

Click here to post a comment

Đăng ký liền tay
Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !