Harrison Aten
asked on
Delete bulk services using text file, then delete host using text file
I am very new to Rest API. Does anyone know how to create a script that will allow me to create an array of servers called host and delete all services attached to the host. In Nagios XI example cURL request to remove service is:
curl -XDELETE "https://nagiosservername/nagiosxi/api/v1/config/service?apikey=JNKelhL55D47u6GvniX7Y8oOlaQQ2V2LI3YjjZnoCKun6qVsLSS0gAOUJUK2P23N&pretty=1&host_name=testapihost&service_description=PING&applyconfig=1"
What I need to do is delete 700 servers from my Nagios XI install. In order to do that I need to first delete all that is configured for each host including all the services and host groups.
curl -XDELETE "https://nagiosservername/nagiosxi/api/v1/config/service?apikey=JNKelhL55D47u6GvniX7Y8oOlaQQ2V2LI3YjjZnoCKun6qVsLSS0gAOUJUK2P23N&pretty=1&host_name=testapihost&service_description=PING&applyconfig=1"
What I need to do is delete 700 servers from my Nagios XI install. In order to do that I need to first delete all that is configured for each host including all the services and host groups.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
- get the list of servers
- get a list of services (general or using another REST call)
- create two foreach loop to remove using the REST call in your question
It's not clear what you've and what you don't