Configure HostGroups for one or multiple hosts in Nagios

Configuration of hostgroups for hosts in Nagios Monitoring

HostGroups :

HostGroups is most feasible and important functionality provide by Nagios. HostGroups is used to group one or multiple hosts, and you will have the option to check all these hosts at one place or on a single page.

Assume you have more than 100 hosts configured on Nagios, and you want a quick look at all your host on Nagios with the status of each service, so such scenario hostgroup feature is useful. You will get the overview of all the hosts and services on the single page or else you need to go under the host tab and then search for a host which you want to check it will be a time-consuming process.

In this article, I am going to show you how to configure and use this compelling feature. Also trying to explain you each part so you will be able to add hostgroups for your hosts quickly.

I started with a direct explanation of host group feature by assuming that you have already running Nagios server and also configured your all hosts on it.
If not or you’re new to Nagios, please refer below step-by-step article of configuration and installation of Nagios server, etc.

You will learn lots of new things about the Nagios Monitoring from my blog “

Configuration of hostgroups on Nagios

Step 1: Create HostGroup File

After default Nagios installation you will not find any file to define hosts for hostgroup. In this situation, you need to create new configuration file under “/usr/local/Nagios/objects” directory where you will have all the Nagios configuration files.
Now we create a .cfg file called “hostsgroup.cfg” and define the hosts in the same file.

vim /usr/local/nagios/objects/hostsgroup.cfg

define hostgroup {
           hostgroup_name    Remote_host
           alias                       Remote_host
           members                nagios_host

Important Parameters used in hostgroup,

Hostgroup_name: Give name of your website or project
Alias: Any short name of your site or project
Members: Give the name which you used in the host.cfg file as host_name.

Note: If you provide wrong value for members parameter then it will not fetch the information for your defined hosts.

Here I have added single member in hostgroup if you are using two web servers for single site then add the host_name of both web server in comma separated form like members webserver1,webserver2

Like above you can add multiple hosts in single hostsgroup file.

Step 2: Permissions

After creating file change the owner and file permission of hostsgroup.cfg file so the Nagios user will be able to read this file.

  • chown nagiosuser.nagios hostsgroup.cfg
  • chmod 664 hostsgroup.cfg

Step 3 : Add hostgroup.cfg file

Now you will need to add a hostsgroup.cfg file in nagios.cfg so Nagios will be able to execute defined parameters from hostsgroup.cfg file.

vim /usr/local/nagios/etc/nagios.cfg

#Add below line

Save and close file.

Step 4 : Check configuration & restart nagios service

After all the necessary configuration we need to check for syntax warnings and restart the Nagios service to reflect the newer changes on Nagios.

To check for errors & warning in configuration,

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Restart Nagios Service

service nagios restart

Open Nagios web interface in the browser and click on “Host Groups” tab in the navigation bar. You will find added host in the host group.

Nagios HostGroups

Also, you will have two sub options or views for the hosts group.

  • Summary View
  • Grid View
Summary View
Grid View

If you’re facing any difficulties while configuring HostsGroup. Please do comment your queries or problem via the comment section, till then stay tuned to for more such valuable articles.

I recommended before implementing this article go through below articles which give you more understanding about Nagios Monitoring.

Latest Comments
  1. stepehen March 2, 2017
  2. manikanth March 12, 2018

Leave a Reply

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