Page 2 of 2

Re: Adding existing services to host via REST API

Posted: Thu Apr 26, 2018 11:30 am
by johncwelch
krutaw wrote:
johncwelch wrote:So to start off, I did read this post: https://support.nagios.com/forum/viewto ... =6&t=36401

But it seems to be for creating new services and adding them to a host. I have a number of existing services (Windows C: Drive utilization for example), and I want to automate adding hosts to that service. All the parameters are already set, I just need to append a new host to that service.

Is this doable via the API?
Here's what we do. I assign services to hostgroups and then update the host to assign a hostgroup to the host, effectively assigning the service to the host. This allows for singular services to be applied across multiple hosts without having to redefine the services over and over. Further, I define OS hostgroups so that standard checks for say windows or linux can be assigned at the host level and then add hostgroups for the custom checks only where necessary.
the problem with hostgroups is that you can't use them with service groups, a royal pain for me. So we've been pulling services out of hostgroups because of how we're wanting to use metrics, which pushes us to servicegroups.

Re: Adding existing services to host via REST API

Posted: Thu Apr 26, 2018 11:31 am
by johncwelch
lmiltchev wrote:@johncwelch let us know if you have any more questions. Thank you!
will do. Looks like the next addition to the REST api needs to be finer-grained control for services, etc., so we can add hosts without rebuilding every time.

Re: Adding existing services to host via REST API

Posted: Thu Apr 26, 2018 3:25 pm
by lmiltchev
Thanks for the feedback @ johncwelch! seems like the biggest number of requests are about the ability to modify existing objects without the need to delete/re-add them. There is a problem at the moment with the host_name, but this should be fixed in the future. REST API is being constantly updated and improved. BTW, there are some cool new features to come in Nagios XI 5.5!