Page 1 of 1

Question on services and templates

Posted: Wed May 01, 2019 5:12 pm
by gregwhite
Can you assign the same services to different service templates, and then assign each service template to a host group? So if you had a disk check service and it was assigned to 3 service templates that are assigned to 3 host groups, the disk service would be handled by each template for the servers in the host group they are assigned to?

Thanks,
Greg

Re: Question on services and templates

Posted: Thu May 02, 2019 12:07 pm
by benjaminsmith
Hi Greg,

Hopefully, I'm understanding the question correctly, so let me know if I'm wrong. In Nagios, groups are simply a way of organizing collections of hosts and services. So hostgroups definitions do not include a template directive.

That said the inheritance rules in Nagios are sophisticated ( see this ). So if you created 3 hostgroups and then three different service templates, each template could contain the hostgroup and those services would inherit the settings from the template associated with the hostgroup. However, since the service is not directly linked to the template, you'll likely get an error for the required settings in XI.

However, I would recommend keeping it simple and create basic templates for the disk service, and assign the correct template when creating a new service. You can also use the Bulk Modifications tool in Nagios to make changes to large numbers or host and services.

Re: Question on services and templates

Posted: Fri May 03, 2019 2:31 pm
by gregwhite
Thanks. I probably didn't clearly explain. We create host groups based on the function of a device. So we may have a group of window servers and have divided them up into 3 host groups. Production, Test and Development. We have defined a set of services that we will check on all window servers such as CPU, Disk, Memory, Netlogon, etc. I want to create 3 service templates each with the same service checks applied to each template. Each of those templates we be assigned to one of those host groups. The difference would be with the production servers we would page on a critical alert where we would just email for a test server. So because the requirements on a production server are different from a test server we would use a different service template even thought the service checks would be the same.
Also, can a host template be assigned to a host group and have devices you add to that host group inherit that template. I tried this and it didn't work so I am wondering if you can't or did I do something wrong.

Thanks,

Re: Question on services and templates

Posted: Fri May 03, 2019 3:36 pm
by npolovenko
@gregwhite
I want to create 3 service templates each with the same service checks applied to each template.
The problem is that if you apply multiple templates to a single service, Nagios will automatically compile everything into a single service configuration. Nagios will not create 3 services with 3 sets of configurations.
Your only option is to create three different service checks and assign them to three host groups.
Also, can a host template be assigned to a host group and have devices you add to that host group inherit that template. I tried this and it didn't work so I am wondering if you can't or did I do something wrong.
That won't work either. Only hosts that are inheriting from this host template will be automatically assigned to the host group.

Host Templates and Service Templates are just layers in the configuration. For example, if a service doesn't have a check command defined, nagios will look into the template and if the template does have the check command defined, then the final service definition that nagios will compile after you click on Apply Configuration will have this check command defined.
Same applies to hostgroups. If no hotgroups are selected for the service, nagios will look at the template and if the template has some hostgroups assigned, then the final service definition will have a hotgroup directive in the compiled configuration.

Code: Select all

    hostgroup_name           inherited from the template