Page 1 of 1
Quick way to create create parent / childs
Posted: Thu Sep 17, 2015 5:26 pm
by rakem
Hello,
I have the latest version of nagios monitoring around 1300 network devices.
I'd like to setup parent / child relationships for each of these devices.
The only way I can see to do this is to add the parent under each host definition, which is pretty cumbersome.
I was hoping I could create some hosts groups and add the parent to the host group, but this doesn't seem to be supported.
Is there another way to do this easily?
Re: Quick way to create create parent / childs
Posted: Fri Sep 18, 2015 7:20 am
by jdalrymple
The purpose of hostgroups is not to generate like configurations for multiple hosts (or anything else) - they are used for creating groups of hosts that share like services and connecting them together.
What you're trying to achieve is done so using templates. Assign the same template to all of your hosts at whatever level and slam the parent definition in there. Note templates stack so you can actually just have a template that looks like this:
Code: Select all
define host {
name hosts-that-have-somehost-as-their-parent
parents somehost
register 0
}
Re: Quick way to create create parent / childs
Posted: Fri Sep 18, 2015 8:55 am
by rakem
Thanks
Could I use a regex in that section so I don't have to list out a few hundred different hosts?
Re: Quick way to create create parent / childs
Posted: Fri Sep 18, 2015 8:59 am
by eloyd
Check out
https://assets.nagios.com/downloads/nag ... ricks.html
Also, you may not need to do anything. If those hosts all have the same template, then you could just add the parent to their existing template line:
In other words, create a template called
hosts-that-have-somehost-as-their-parent as @jdalrymple suggested, then find all your hosts and find all the "use" lines in those hosts, and just add ", hosts-that-have-somehost-as-their-parent" to the end of the line. You can use multiple templates.
Re: Quick way to create create parent / childs
Posted: Fri Sep 18, 2015 1:25 pm
by hsmith
Thank you, Eric!
@rakem, let us know if you need any help.