Page 1 of 2

best practice with templates and inheritance

Posted: Fri Feb 21, 2020 3:11 pm
by pspagnola
I am new to nagios, but have done a bit of reading regarding inheritance and precedence.

Clarifying questions:
- if I apply multiple templates to a host the top template takes precedence for any values that are in multiple templates?
- if 3 templates are applied via the host using GUI (top to bottom order of 1,2,3) and 3 templates are applied via the host group (top to bottom order of 1,2,3) , what is the precedence order? would host template 1 be the highest precedence and host group template 3 be the lowest?
- locally defined settings on a host take precedence over a template, correct?
-- So if I want settings from a template to have top precedence, but adding a host from the config wizard always sets local values, then I should add new hosts without using the wizard?

would using the bulk modification wizard simplify any of this?
Can I edit a configuration wizard to apply custom templates and to not apply certain local values?

Re: best practice with templates and inheritance

Posted: Fri Feb 21, 2020 5:53 pm
by mbellerue
I usually have a tough time visualizing this properly because I usually go the other way from most people. But in my terms, whatever is at the end of the chain takes precedence. Let's look at some templates that exist by default, and a made-up host.

General Template -> Linux-server -> MyHost

As you go further right, you override whatever is to the left. So that when you get down to the actual host, you can always override anything that was applied via template. Does that make sense?

So yes, if you plan to utilize templates heavily, wizards will not be your friend. ... Unless you make your own. I would not recommend customizing the wizards, as they do get updated, and if something messes up in the wizards and we're trying to help you with it, it may send us all down a rabbit hole that could have been avoided.

However, you do have the option to create your own wizard.
https://assets.nagios.com/downloads/nag ... ios-XI.pdf

That may be a bit of a heavy handed approach, depending on your own personal style of administration. You may prefer to just script the addition of hosts and services via the API. I would link to the XI documentation for the API, but it's actually baked into XI. Head over to Help -> API Docs.

Templates are definitely the way to go for large setups, or environments where you're segregating hosts and services by SLA. It can be time consuming to troubleshoot down the road, but it's totally worth it.

Re: best practice with templates and inheritance

Posted: Wed Feb 26, 2020 12:45 pm
by pspagnola
thank you for the help.

if I ever have time I may try making a wizard, but maybe I just need more knowledge in the area of adding hosts and services without a wizard.



would it be reasonable for me to submit a feature request to have an "effective settings" button on a host config screen? clicking the button would show the effective settings (only the settings with highest precedence) from all upstream templates.

Re: best practice with templates and inheritance

Posted: Wed Feb 26, 2020 3:04 pm
by benjaminsmith
Hello @pspagnola,

No, that seems reasonable to me, I'll get a request submitted. Right now, I would recommend checking the /usr/local/nagios/var/objects.cache file to see the final results from template inheritance.

Re: best practice with templates and inheritance

Posted: Fri Feb 28, 2020 2:21 pm
by pspagnola
Thank you!

Re: best practice with templates and inheritance

Posted: Fri Feb 28, 2020 2:42 pm
by benjaminsmith
Hi,

Also, If you not aware of it already, you can view object relationships in XI in the CCM under the Actions menu when listing of hosts or services.
host-templates.png

Re: best practice with templates and inheritance

Posted: Mon Mar 02, 2020 8:57 pm
by silverbenz
Hi @pspagnola,

There's an XI Component available on Nagios Exchange called "View Object Configuration" that lets you see the effective settings once you've created a Host or Service. This isn't in the configuration screen, but it's been quite useful for me nonetheless.

Once the Host/Service is created, go to the Status Detail view for the specific Host/Service and you'll see a new tab with an icon that looks like three gears.

If you search "nagios exchange view object configuration" it should be one of the top results.

Cheers,
Ben.

Re: best practice with templates and inheritance

Posted: Mon Mar 02, 2020 11:08 pm
by Box293
Thanks for the suggestion @silverbenz

Re: best practice with templates and inheritance

Posted: Tue Mar 03, 2020 5:31 am
by optionstechnology
One tool I have used before is the "Bulk Host Cloning and Import" wizard

Create a host to use as a 'template' - this host has nothing at all set locally - only the templates you want assigned to it

At the bottom of the wizard page there is a data box where you can paste in a csv of server names - all of these servers will inherit the templates from your template host - if you assign all of the services you want added to a hostgroup and then assign that host to the same hostgroup it will inherit everything it needs from the wizard

Re: best practice with templates and inheritance

Posted: Tue Mar 03, 2020 7:47 am
by scottwilkerson
Thanks for the suggestion @optionstechnology