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!
Updating hostgroups via api
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Updating hostgroups via api
You probably want to add the hostgroup to the host config.
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/host/simon.blah.com?apikey=QclTD3pVVHWiN8Gt4EZYfjKhC5gfJgOPL9Ilrogm5sXREEkXuDVMcF44ZDjJanOU&pretty=1&hostgroups=Elasticsearch-servers&applyconfig=1"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"