How to add remote hosts to the Icinga2 monitoring system

You have Icinga2 up and running, but it's not seeing any remote hosts. Jack Wallen shows you what to do.

icingahero.jpg
Image: Jack Wallen

Icinga2 is an outstanding, enterprise-class, data center server monitoring tool. With this tool up and running (How to install the Icinga2 Monitoring tool on Ubuntu Server 16.04), you can stay apprised on what's happening with your servers from a central location. This makes it easy for you to monitor performance and services in real time, and even be notified of outages.

The one caveat to Icinga2 is that it doesn't offer a means to add hosts, via the web-based GUI. Because of that, you must manually add any server to be monitored, via the terminal window. Fortunately, that process isn't terribly difficult, but it does require you to work from the command line.

Let's walk through the process of adding a remote host for Icinga2 and check it for basic availability. I'll configure the system to monitor a Nextcloud server at IP address 192.168.1.10. The monitoring we'll set up is fairly basic and will run a regular check on the server availability. The first configuration will simply use a ping test to check server uptime, and the second will use a basic template and search for a website at the document root URL. For example, Icinga2 will search for a site or page (such as index.php or index.html) at the / directory of either the domain or the IP address. Should Icinga2 not be able to contact the configured remote host, it will automatically alert the icinga admins of the situation.

SEE: Data center automation research report 2018: Despite growth in data, automation adoption remains slow (Tech Pro Research)

Let's configure.

Adding the remote host

To add the new remote host, SSH (or log into) your Icinga2 server. First, we'll configure a remote host check to make sure the server is simply up and running. At the terminal window, issue the command:

sudo nano /etc/icinga2/conf.d/hosts.conf

The file you now have open is the general host configuration. You want to append all new hosts at the bottom of this file. Scroll to the bottom and paste the following contents:

object Host "HOSTNAME" {
  import "generic-host"
  address = "SERVER_IP"
  check_command = "hostalive"
}

where HOSTNAME is the hostname of the remote server and SERVER_IP is the IP address of the server.

Save and close that file.

Restart Icinga2 with the command:

sudo systemctl restart icinga2

Checking the newly added host

Icinga2 will pick up the new host very quickly. Point your browser to http://SERVER_IP/icingaweb2 (where SERVER_IP is the IP address of the Icinga server), and you should immediately see the newly added host (Figure A).

Figure A

Figure A

Our newly added remote host.


Checking HTTP

Now let's configure a remote host that will check the status of an HTTP server. The configuration is mostly the same, only the check_command option is different. So issue the command:

sudo nano /etc/icinga2/conf.d/hosts.conf

This time scroll to the bottom and change:

check_command = "hostalive"

To:

check_command = "http"

Save and close that file. Restart Icinga2 with the command:

sudo systemctl restart icinga2

Head over to the Icinga2 website and go to Overview | Hosts. You should now see the remote host being checked for the HTTP service (Figure B).

Figure B

Figure B

HTTP is good to go on 192.168.1.10.


Our HTTP server is now being monitored by Icinga2.

More than meets the eye

We now have the ability to check to see if a site/server is down or having problems. Icinga2 is far more complex than that, and soon we'll dive further down this rabbit hole to set up much more complicated remote host monitoring (that can monitor CPU load, number of process, disk space, and much more). Until then, enjoy keeping tabs on your remote server uptime with Icinga2.

Also see

By Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.