Page 1 of 1

setting both host and service check interval from templates

Posted: Mon Dec 16, 2013 9:49 am
by geekabit
Hi,

I'm currently working on a nagios server for our office, co-location and several servers for our customers. Most of the monitoring is working fine, but there is one issue I can't seem to find a solution for. Let's assume there are two servers (host_colocation and host_customer), one running in our co-location, the other running on our customers site. Both servers have OurSoftware (tm) running. I want to monitor our server (both host and service) very often, let's say every minute. There is no need to monitor our customers server (both host and service) that often. Once every hour is enough. The host check_interval can be set with templates. This works fine. But I want to set the service check_interval to the same value as the host check_interval. Below is a simplified version of the checks I'm currently using. Every host uses two templates. One for location, one for services.

This is the location template for all our co-location hosts. All these hosts are checked once every minute.
define host{
register 0
name template_host_colocation
use template_host_generic
check_interval 1
retry_interval 1
}

This is the location template for our customers' hosts. All these host are checked once every 60 minutes.
define host{
register 0
name template_host_customer
use template_host_generic
check_interval 60
retry_interval 60
}

There is the service template for our software. It is a host template for all hosts running our software. The template sets some custom variables (not shown in this example) and puts the host in a hostgroup.
define host{
register 0
name template_host_OurSoftware
hostgroups +hostgroup_OurSoftware
}

The hostgroup definition.
define hostgroup{
hostgroup_name hostgroup_OurSoftware
}

Every host in this hostgroup automatically gets a check for this service.
define service{
use template_service_generic
hostgroup_name hostgroup_OurSoftware
service_description OurSoftware
check_command check_OurSoftware
}

This is the definition for the co-location host. It uses one template for location and one template for services. The host check interval is inherited.
define host{
use template_host_colocation,template_host_OurSoftware
host_name colocation.example.org
}

This is the definition of the customer host.
define host{
use template_host_customer,template_host_OurSoftware
host_name customer.example.org
}

How can I set the check_interval for the services to different values on both servers? Can this be done in one of the templates or hostgroups? It can probably be set in a service template or servicegroup, but how would I add those to this host definition?

Cheers,
Maarten

Re: setting both host and service check interval from templa

Posted: Mon Dec 16, 2013 1:16 pm
by lmiltchev
Have you tried setting up service templates (for example: "template_service_colocation" and "template_service_customer"), and use them for services as you do with hosts and host templates?

Re: setting both host and service check interval from templa

Posted: Mon Dec 30, 2013 4:31 pm
by geekabit
I made some service templates, but that alone didn't fix the problem. There's a template_ service_customer, which checks every 60 minutes and a template_ service_colocation which checks every minute. The problem is there's no way to use one service template in one case and another service template in another case. In the end I fixed it by making 2 hostgroups instead of 1. When the template_host_colocation is included all service checks are defined with template_ service_colocation, when template_host_customer is used all service checks are defined with template_ service_customer. So all service checks are defined twice, once based on the colocation template and once based on the customer template. I hoped to only define them once, but at least it works now.

Cheers,
Maarten

Re: setting both host and service check interval from templa

Posted: Thu Jan 02, 2014 11:32 am
by lmiltchev
I am glad your issue have been resolved! I am locking this topic.