Updating hostgroups via api

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
kmackay
Posts: 1
Joined: Fri Jul 26, 2019 8:56 am

Updating hostgroups via api

Post by kmackay »

Hi:

I'm attempting to update a hostgroup (adding 'simon.blah.com' to the 'Elasticsearch-servers' hostgroup via the api using the following:
curl -XPUT "http://watcher/nagiosxi/api/v1/config/h ... lyconfig=1"

simon.blah.com is an actual host in our config and when I execute the above command, it says that it's successful but when I check in the interface, it still returns the same list of servers as before the 'update'?

Am I missing a parameter or is this even possible via the api?

Thanks!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Updating hostgroups via api

Post by scottwilkerson »

You probably want to add the hostgroup to the host config.

Code: Select all

curl -XPUT "http://watcher/nagiosxi/api/v1/config/host/simon.blah.com?apikey=QclTD3pVVHWiN8Gt4EZYfjKhC5gfJgOPL9Ilrogm5sXREEkXuDVMcF44ZDjJanOU&pretty=1&hostgroups=Elasticsearch-servers&applyconfig=1"
Alternatively, you can add it to the hostgroup like you were doing but you would update the members field not the host_name field, key point being this will replace everything that is currently in the list, so you would need to pass all the existing members plus the new one

e.g.

Code: Select all

curl -XPUT "http://watcher/nagiosxi/api/v1/config/hostgroup/Elasticsearch-servers?apikey=QclTD3pVVHWiN8Gt4EZYfjKhC5gfJgOPL9Ilrogm5sXREEkXuDVMcF44ZDjJanOU&pretty=1&members=originalMember,originalMember2,originalMember3,simon.blah.com&applyconfig=1"
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked