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

Channel: Linux
Abstract: master name & IP address as per your setup. Now restart the icinga2 service & we can visit ‘icingaweb2’ page to start monitoring the host servicesour

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,

[[email protected] ~]# firewall-cmd --permanent --add-port=5665/tcp
[[email protected] ~]# 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,

[[email protected] ~]$ 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,

Now restart the icinga2 service to implement the changes,

[[email protected] ~]$ 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,

[[email protected] ~]$ sudo icinga2 pki ticket --cn lnxclient.example.com
9e26a5966cd6e2d6593448214cab8d5e7bd61d59
[[email protected] ~]$

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).

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

Now we will install the icinga 2,

[[email protected] ~]# yum install icinga2 -y

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

[[email protected] ~]# systemctl start icinga2 && systemctl enable icinga2

Now start the  icinga setup wizard from host,

[[email protected] ~]# icinga2 node wizard

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,

[[email protected] ~]# 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.

[[email protected] ~]$ sudo -i
[[email protected] ~]# 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,

[[email protected] ~]# 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,

Also we can see all the services from main dashboard,

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,

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,

[[email protected] ~]# icinga2 pki ticket --cn fileserver
e2c0196f34076bde7463efe20863827b8964b062
[[email protected] ~]#

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

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.

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

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

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

[[email protected] ~]# 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

[[email protected] ~]# 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.

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

Ref From: linuxtechi

Related articles