Page 1 of 1

Bulk modify Hostgroup inheritance

Posted: Thu Apr 18, 2019 12:01 pm
by jvaira
Hello,
I am looking for a way to enable hostgroup inheritance ( at the host level ) for all of our hosts. I thought setting this in the host template would do the trick but it looks like it needs to be set in both places to take affect. I have attached a screen shot for reference.

Re: Bulk modify Hostgroup inheritance

Posted: Thu Apr 18, 2019 3:26 pm
by cdienger
Hostgroups should be inheritable from a template. Did you do the following:

1. Edit the template to include a host group
2. apply the template to a host

?

It's may not be obvious in the UI, but if you look in /var/nagiosramdisk/objects.cache or /usr/local/nagios/var/objects.cache, and search for "hostgroup_name <yourhostgroupname> you should find a definition with all the host members.

Re: Bulk modify Hostgroup inheritance

Posted: Thu Apr 18, 2019 5:36 pm
by jvaira
Hello @cdienger, Sorry maybe I wasn't explaining this very clearly. What I am trying to do is enable the additive option for hostgroup inheritance so that I can define a hostgroup in a template as well as within the hostgroups section of the host.

Re: Bulk modify Hostgroup inheritance

Posted: Fri Apr 19, 2019 12:58 pm
by cdienger
Ah. Thanks for the clarification. I'm not seeing a good way to do it in bulk in the web UI, but the setting is in the database:

Code: Select all

echo "select host_name, hostgroups_tploptions from tbl_host;" | mysql -uroot -pnagiosxi -Dnagiosql
The value in hostgroups_tploptins controls what is selected - 0 for additive, 1 for Null, 2 for standard.

Updating a current host would look like:

Code: Select all

update tbl_host set hostgroups_tploptions = 0 where host_name = localhost
Setting the default value(when adding a new host) to additive can be done too:

Code: Select all

ALTER TABLE tbl_host ALTER hostgroups_tploptions SET DEFAULT 0
We don't usually like making changes via direct sql calls like this since they not really tested and there's a risk of breaking things, so make sure to make a backup as a precaution if you go this route.