Bind service with host group


#1

Hi, I’m having a problem with nagios/service.cfg file. We have many host groups, each host contains several services to be monitored, this is an example from web-log-test service on web machines,

define service{
use generic-service ; Name of service template to use

    host_name                       web11
    service_description             WEB-LOGIN-TEST
    is_volatile                     0
    check_period                    24x7
    max_check_attempts              3
    normal_check_interval           60
    retry_check_interval            60
    contact_groups                  opsys-dba
    notification_interval           240
    notification_period             24x7
    notification_options            c,r
    check_command                   check_web_login
    }

define service{
use generic-service ; Name of service template to use

    host_name                       web12
    service_description             WEB-LOGIN-TEST
    is_volatile                     0
    check_period                    24x7
    max_check_attempts              3   
    normal_check_interval           60
    retry_check_interval            60
    contact_groups                  opsys-dba
    notification_interval           240      
    notification_period             24x7
    notification_options            c,r 
    check_command                   check_web_login
    }

define service{
use generic-service ; Name of service template to use

    host_name                       web13
    service_description             WEB-LOGIN-TEST
    is_volatile                     0
    check_period                    24x7
    max_check_attempts              3
    normal_check_interval           60
    retry_check_interval            60
    contact_groups                  opsys-dba
    notification_interval           240
    notification_period             24x7
    notification_options            c,r
    check_command                   check_web_login
    }

You can imagine the service file is pretty messy containing n_hosts X n_services blocks. Is there a way to bind service with “host group” instead of the individual host ?


#2

Most of what you have shown is duplicated over and over. The intent of using “use generic-service”, is so you don’t have to do that. Define them once in the template, and then simply define “use templatename” once for each host/service.