Page 1 of 1

Adding a hostgroup to a host definition using REST API

Posted: Thu Apr 27, 2017 4:41 pm
by ddaluka
Hi,

I have added few hosts in Nagiosxi and I have added hostgroups in the host definitions instead of adding them as a member in hostgroup definition. I now want to add another hostgroup to one of the hosts keeping its already added hostgroups intact.

I know I can do it from UI using manage hostgroups but can someone help me if there is a way to do it using command line? May be using REST API or Database query? I need it to put in a script.

I am OK to delete the hosts and recreate but I first need the list of already existing hostgroups in that host definition before deleting and recreating.

I have tried following REST API but it doesn't give hostgroups list in the output.

http://NagiosHost/nagiosxi/api/v1/objec ... v&pretty=1

Thanks for your help in advance.

Re: Adding a hostgroup to a host definition using REST API

Posted: Thu Apr 27, 2017 10:57 pm
by vazudevan
I suppose you should be using object/hostgroup part of API instead..

this should list all your host groups.
http://nagioshost/nagiosxi/api/v1/objec ... v&pretty=1

Re: Adding a hostgroup to a host definition using REST API

Posted: Fri Apr 28, 2017 7:45 am
by tacolover101
check out this doc which you might find handy -
Nagios-Automating-with-Nagios-XI.pdf

Re: Adding a hostgroup to a host definition using REST API

Posted: Fri Apr 28, 2017 10:10 am
by tmcdonald
Thanks for the input, folks! @ddaluka let us know if you have further questions.

Re: Adding a hostgroup to a host definition using REST API

Posted: Thu May 04, 2017 8:25 am
by ddaluka
Hi All,

Thank you for your inputs. I have now managed to get this information from database as a list of hostgroups for a host and then recreating the hosts definition after appending new hostgroups using perl script.

Re: Adding a hostgroup to a host definition using REST API

Posted: Thu May 04, 2017 11:02 am
by mcapra
Awesome! Did you have additional questions regarding this topic, or can we close this thread?

Re: Adding a hostgroup to a host definition using REST API

Posted: Mon May 08, 2017 10:27 am
by ddaluka
Yes.. We can close this thread. Thanks for your support