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
Creating host with hostgroups using Nagios XI REST api
Re: Creating host with hostgroups using Nagios XI REST api
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¬ification_interval=5¬ification_period=24x7&applyconfig=1&hostgroups=group1%2Cgroup2"
%2C is a URL encoded comma and only needed if adding the host to multiple groups.
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¬ification_interval=5¬ification_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.
Re: Creating host with hostgroups using Nagios XI REST api
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
https://outsideit.net
Re: Creating host with hostgroups using Nagios XI REST api
There is:
curl -XGET "http://nagios_xi/nagiosxi/api/v1/objects/hostgroupmembers?apikey=api_key&pretty=1&host_name=hostname"
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.