Configuring host roles using groups
In this recipe, we'll learn how to use the abstraction of host and service groups to our 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 by using a hostgroup structure, and then assigning relevant services to the hostgroup, rather than to the hosts individually.
Getting ready
You will need to have a server running Nagios Core 3.0 or later, have access to the command line to change its directories, and understand the basics of how host and service groups work. These are covered in the Creating a new hostgroup and Creating a new servicegroup recipes in Chapter 1.
In this example, we'll create two simple hostgroups; one called servers
, for which a PING
check should be made for its member hosts, and another called webservers
, which should include HTTP
checks for its member hosts. Once this is set up, we'll then add an example host sparta.naginet
to both groups...