Creating host with hostgroups using Nagios XI REST api

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Creating host with hostgroups using Nagios XI REST api

Post by WillemDH »

Hello,

We have a need to add and synchronize hostgroups to hosts dynamically in Nagios XI, but we noticed this still isn't possible using the Nagios XI REST api? With an continuously changing environment, it's important that we can synchronize role hostgroups etc with our cmdb.

When would adding hosts with hostgroups be possible with the Nagios XI REST api?

Grtz

Willem
Nagios XI 5.8.1
https://outsideit.net
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Creating host with hostgroups using Nagios XI REST api

Post by cdienger »

Tested on 5.5.8, adding a host with hostgroups:

curl -XPOST "http://nagios_xi/nagiosxi/api/v1/config/host?apikey=api_key&pretty=1" -d "host_name=testapihost&address=127.0.0.1&check_command=check_ping\!3000,80%\!5000,100%&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin&notification_interval=5&notification_period=24x7&applyconfig=1&hostgroups=group1%2Cgroup2"

%2C is a URL encoded comma and only needed if adding the host to multiple groups.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Creating host with hostgroups using Nagios XI REST api

Post by WillemDH »

Haa Thanks, that seems to work indeed. Is it also possible to get all the hostgroups a host belongs to with the REST api?
Nagios XI 5.8.1
https://outsideit.net
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Creating host with hostgroups using Nagios XI REST api

Post by cdienger »

There is:

curl -XGET "http://nagios_xi/nagiosxi/api/v1/objects/hostgroupmembers?apikey=api_key&pretty=1&host_name=hostname"
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked