Quick way to create create parent / childs

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
rakem
Posts: 3
Joined: Tue May 08, 2012 7:27 pm

Quick way to create create parent / childs

Post 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?
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Quick way to create create parent / childs

Post 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
}
rakem
Posts: 3
Joined: Tue May 08, 2012 7:27 pm

Re: Quick way to create create parent / childs

Post by rakem »

Thanks

Could I use a regex in that section so I don't have to list out a few hundred different hosts?
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Quick way to create create parent / childs

Post 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.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Quick way to create create parent / childs

Post by hsmith »

Thank you, Eric!


@rakem, let us know if you need any help.
Former Nagios Employee.
me.
Locked