Skip to main content

Nagios – Using HostGroups

By October 25, 2013September 12th, 2022No Comments

Monitoring with Nagios CoreFor system administration we will be used to using groups to help us manage all aspects of our tasks and monitoring with Nagios Core is no different. We saw in a previous tutorial that we could create a service to monitor NTP. We that was fine as we only have the one NTP server that supplies time to other hosts, however, for services such as SSH we will have many servers to monitor. The default Nagios 3 package on Ubuntu defines a services for SSH and it is attached to a host group, ssh-servers. Host groups, as the name suggests groups hosts and can be used to assign services. User can become a member of the groups through the group definition itself and the members attribute as we can see from the definition below that just has the localhost as a member. Multiple host names should be separated by commas.

define hostgroup {
   hostgroup_name  ssh-servers
   alias           SSH servers
   members         localhost

Hosts may also become a member of the group from with the host definition, using the hostgroups attribute.  Multiple hostgroups should be separated by commas.

define host {
  host_name store.tup.local
  alias store
  hostgroups ssh-servers
  max_check_attempts 3
  check_period 24x7
  check_command check-host-alive
  contacts root
  notification_interval 60
  notification_period 24x7

By becoming a member of the hostgroup ssh-servers the SSH service is monitored on my store server. There is,  as you may guess, a service definition in place to monitor SSH. This, too, was part of the standard Nagios package installed onto Ubuntu.

define service {
        hostgroup_name                  ssh-servers
        service_description             SSH
        check_command                   check_ssh
        use                             generic-service
        notification_interval           0 ; set > 0 if you want to be renotified