best practice with templates and inheritance

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
pspagnola
Posts: 51
Joined: Thu Nov 21, 2019 4:40 pm

best practice with templates and inheritance

Post 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?
Nagios v5.6.12 ~200 hosts 500+ services.
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: best practice with templates and inheritance

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
pspagnola
Posts: 51
Joined: Thu Nov 21, 2019 4:40 pm

Re: best practice with templates and inheritance

Post 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.
Nagios v5.6.12 ~200 hosts 500+ services.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: best practice with templates and inheritance

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
pspagnola
Posts: 51
Joined: Thu Nov 21, 2019 4:40 pm

Re: best practice with templates and inheritance

Post by pspagnola »

Thank you!
Nagios v5.6.12 ~200 hosts 500+ services.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: best practice with templates and inheritance

Post 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
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
silverbenz
Posts: 21
Joined: Wed Nov 14, 2012 9:06 pm

Re: best practice with templates and inheritance

Post 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.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: best practice with templates and inheritance

Post by Box293 »

Thanks for the suggestion @silverbenz
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
optionstechnology
Posts: 228
Joined: Thu Nov 17, 2016 11:26 am

Re: best practice with templates and inheritance

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: best practice with templates and inheritance

Post by scottwilkerson »

Thanks for the suggestion @optionstechnology
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked