Is it possible to add a host to a hostgroup where both are previously existing via the API? Say I have host_1 through host_1000 and I want to add them all to hostgroup_3 via the API, can I do that?
Also, is there a way to adjust check_interval values via the API? I tried to modify the value for all hosts in a hostgroup but it corrupted the configs and wouldn't let me apply.
API questions
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: API questions
Hello, @andrewatmacys. You can submit an API command to add a new hostgroup, but specify the same hostgorup name. That way the command is going to override the existing hostgroup definition and will allow you to add new hosts.
curl -XPOST "http://192.168.3.3/nagiosxi/api/v1/conf ... y&pretty=1" -d "hostgroup_name=testapihostgroup&alias=HostGroup&members=host1&applyconfig=1" -k -L
Same applies to overiding host configs with API commands. I don't think you can bulk modify all hosts in a hostgroup with an API command. Can you show me how you tried doing that?curl -XPOST "http://192.168.3.3/nagiosxi/api/v1/conf ... y&pretty=1" -d "hostgroup_name=testapihostgroup&alias=HostGroup&members=host1,host2,host3,...,host100&applyconfig=1" -k -L
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
andrewatmacys
- Posts: 114
- Joined: Tue Feb 06, 2018 9:25 am
Re: API questions
The bulk modification was a separate event, I should have clarified that from the start, my mistake.
So I would have to individually list every host we wanted to modify in the case of the check_interval setting?
So I would have to individually list every host we wanted to modify in the case of the check_interval setting?
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: API questions
Via the API yes.andrewatmacys wrote:The bulk modification was a separate event, I should have clarified that from the start, my mistake.
So I would have to individually list every host we wanted to modify in the case of the check_interval setting?
Or you can change settings in bulk via
CCM -> Bulk Modifications Tool
Click "Change a single configuration option"