In this recipe, you'll learn how to use the abstraction of host and service groups to your advantage in order to build a configuration where hosts and services can be added or removed more easily. We'll do this by defining roles for hosts using a hostgroup structure and then assigning relevant services to the hostgroup rather than to the hosts individually.
You will need to have a server running Nagios Core 4.0 or later, have access to the command line to change its directories, and understand the basics of how hostgroups and servicegroups work. These are covered in the recipes Creating a new hostgroup and Creating a new servicegroup in Chapter 1, Understanding Hosts, Services, and Contacts.
In this example, we'll create two simple hostgroups; one will be called
servers, for which a
PING check should be made for its member hosts, and another will be called
webservers, which should include
HTTP checks for its member hosts. Once this is set up...