How to add remote Linux and Windows Host to Icinga 2 for Monitoring

As discussed in our earlier article, Icinga2 is an open source tool for monitoring the IT resources. We have already covered the installation of icinga2 on CentOS / RHEL 7 machines &  in this tutorial, we are going to learn to add Windows & Linux machine to Icinga2 for monitoring.

Read AlsoHow to Install and Configure Icinga 2 / Icinga Web 2 on CentOS 7 and RHEL 7

The default port that icinga2 uses for monitoring is 5665 & it should be opened up in firewall to maintain a connection between master & host (called parent & child for icinga2), Use below command to open 5665 port in os firewall,

[root@icinga ~]# firewall-cmd --permanent --add-port=5665/tcp
[root@icinga ~]# firewall-cmd --reload

Configuring Master server (Icinga 2 Server)

Firstly we need to prepare the master server to connect to host systems. We will run ‘icinga 2 setup wizard’ for the same, run the following command from the terminal,

[linuxtechi@icinga2 ~]$ sudo icinga2 node wizard

First it will prompt to specify if its master or client setup, you need to press ‘n’ to install master setup. Rest options can be kept default or can be changed as per your needs,

icinga2-node-wizard-setup

Now restart the icinga2 service to implement the changes,

[linuxtechi@icinga ~]$ sudo service icinga2 restart

Now we also need to generate a ticket for our host, run the following command from terminal to generate a ticket for your host,

[linuxtechi@icinga ~]$ sudo icinga2 pki ticket --cn lnxclient.example.com
9e26a5966cd6e2d6593448214cab8d5e7bd61d59
[linuxtechi@icinga ~]$

Here “lnxclient.example.com”  is the name of the linux host that we want to add to Icinga for monitoring   & “9e26a5966cd6e2d6593448214cab8d5e7bd61d59” is the generated ticket, which we will need later.

Add & configure Linux machine ( RHEL / CentOS 7) to Icinga 2

To configure the host, we wil first install the icinga2 packages (same as we did on master server).

[root@lnxclient ~]# yum install https://packages.icinga.com/epel/icinga-rpm-release-7-latest.noarch.rpm

Now we will install the icinga 2,

[root@lnxclient ~]# yum install icinga2 -y

Once packages have been installed, start the icinga2 service & enable it for boot,

[root@lnxclient ~]# systemctl start icinga2 && systemctl enable icinga2

Now start the  icinga setup wizard from host,

[root@lnxclient ~]# icinga2 node wizard

icinga-node-wizard-client

Here we need to press ‘y’ on the first prompt i.e. ‘Specify if its satellite/client setup’, after that we need to press ‘y’ again for prompt ‘Do you want to establish a connection to parent node from this node’  &  then also provide the master server information. Also we will be asked to enter the ticket which we created earlier, specify that as well.

After that’s done, restart the icinga2 service to implement the changes,

[root@lnxclient ~]# systemctl restart icinga2

We will now update the host node information on master, switch back to the master & we will define host or client (lnxclient.example.com) in “/etc/icinga2/conf.d/hosts.conf” file.

Add the following content at the end of file.

[linuxtechi@icinga ~]$ sudo -i
[root@icinga ~]# vi /etc/icinga2/conf.d/hosts.conf
…………………………………………………………………………

object Zone "lnxclient.example.com" {
  endpoints = [ "lnxclient.example.com" ]
  parent = "icinga.example.com"
}
object Endpoint "lnxclient.example.com" {
  host = "192.168.1.3"
}
object Host "lnxclient.example.com" {
  import "generic-host"
  address = "192.168.1.3"
  vars.http_vhosts["http"] = {
    http_uri = "/"
  }
    vars.disks["disk"] = {
    }
  vars.disks["disk /"] = {
    disk_partitions = "/"
  }
  vars.notification["mail"] = {
    groups = [ "icingaadmins" ]
  }
  vars.client_endpoint = "lnxclient.example.com"
}

Save and exit the file

Change the host, master name & IP address as per your setup. Now restart the icinga2 service & we can visit ‘icingaweb2’ page to start monitoring the host services,

[root@icinga ~]# systemctl restart icinga2

Note:- For more information in configuring more services, read the official Icinga2 documentation at (https://www.icinga.com/docs/icinga2/latest/doc/04-configuring-icinga-2/)

Now open the Icinga web 2 portal with the following URL,

http://192.168.1.2/icingaweb2

& provide your credentials.  Inside the dashboard, go to ‘Overview‘ then ‘Hosts‘ to check the hosts that are being monitored by icinga2. As seen in the below screenshot, our server is monitoring localhost or icinga.example.com  & the host node we just added,

Hosts-Details-Icinga2Web

Also we can see all the services from main dashboard,

Icinga2-Services-Hosts

We will now add a Windows host on icinga2 server for monitoring.

Add & Configure a Windows host (Windows Server 2012 R2) to Icinga 2

Adding a windows host to icinga2 is also pretty easy & straight forward. For Windows system, we need to download a MSI installer from the official website based on your system (http://packages.icinga.com/windows/).

Once downloaded, run the installer & complete the initial installation by just pressing next. Once the installation has been complete, Run the setup wizard & we will get the following screen,

Token-Windows-Server-Icinga2

Here mention a hostname that you want your Windows system to be identified with & then create a ticket with that hostname from the icinga server as we did for Linux system, with the following command,

[root@icinga ~]# icinga2 pki ticket --cn fileserver
e2c0196f34076bde7463efe20863827b8964b062
[root@icinga ~]#

Now click on ‘Add’ to add the information , we will then be asked to enter our Icinga2 server name & IP address,

Icinga-Endpoints-windows-Host

After it has been added, check the following boxes ‘Listen for connection from master/satellite instance(s) ’, ‘Accept commands from master/satellite instance(s)’ & also ‘Accept config updates from master/satellite instance(s)’ & press ‘Next’ to continue the setup.

Allow-Commands-From-Icinga2-Server

We will then be asked to verify the information, check & press ‘Next‘ to continue,

Verify-SSL-Certs-Icinga-Server-windows-Host

Configuration will then complete, click ‘Finish‘ to exit out of setup

Finish-windows-Configuration-Icinga2

Now go back to master server, & we  will now update the windows host node information on master & add the following content at the end of  file  “/etc/icinga2/conf.d/hosts.conf

[root@icinga ~]# vi /etc/icinga2/conf.d/hosts.conf
…………………………………………………………
object Zone "fileserver" {
  endpoints = [ "fileserver" ]
  parent = "icinga.example.com"
}
object Endpoint "fileserver" {
  host = "192.168.1.4"
}
object Host "fileserver" {
  import "generic-host"
  address = "192.168.1.4"
  vars.http_vhosts["http"] = {
    http_uri = "/"
  }
    vars.disks["disk"] = {
    }
  vars.disks["disk /"] = {
    disk_partitions = "/"
  }
  vars.notification["mail"] = {
    groups = [ "icingaadmins" ]
  }
  vars.client_endpoint = "fileserver"
}

Save and exit the file and then restart icinga2 service

[root@icinga ~]# systemctl restart icinga2

Now open the icinga web 2 portal with the following URL,

http://192.168.1.2/icingaweb2

Now go to ‘Overview’ then ‘Hosts’ to check the hosts that are being monitored by icinga 2.

Windows-Hosts -Icinga-Web

With this we end our tutorial. Please feel free to send in your questions & queries.

11 thoughts on “How to add remote Linux and Windows Host to Icinga 2 for Monitoring”

  1. I want to use nrpe plugins to monitor remote client in icinga2 server. can you please help me with any suggestion or tutorial for using nrpe plugins.

    1. I have the same problem than you, everything seems working except for the disks size ? Did you find any solution, it could help me ?

  2. Mayby you can do tutorial to icinga director or give any link to good tutorial how to create host in icinga director.
    Regards,

  3. Unable to restart icinga: Job for icinga2.service failed because the control process exited with error code. See “systemctl status icinga2.service” and “journalctl -xe” for details.

    1. if you had udpated host.conf file with wrong value then it will through such exception. you can check the detail log using below command. systemctl status icinga2.

  4. Good, I followed in tutorial at the foot of the letter and it does not work … when I go to icingaweb2> overview> Hosts … I do not get anything says “No hosts found matching the filter” HELP

Leave a Comment

Your email address will not be published. Required fields are marked *