Unable to delete service using curl 'XDELTE' on Nagios xi 5.

This support forum board is for support questions relating to Nagios xi, our flagship commercial network monitoring solution.
rthomas7
Posts: 5
Joined: Thu Mar 07, 2019 7:13 am

Unable to delete service using curl 'XDELTE' on Nagios xi 5.

Post by rthomas7 »

This is the command I am trying to use
curl -XDELETE "https://<Nagios xi Host Name>/nagiosxi/api/v1/config/service?apikey=tBNRmsqitghiurFNECXKOu7RjkI6AEOX7p8egoCQKvelfSoSLmCvAB&pretty=1&host_name=testapihost&service_description=Disk Usage on /usr/local&applyconfig=1" -k

Here is the error I get.

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>
Collapse

Could someone help me with this? . I have got 1000+ servers and I need to delete/remove a 'Disk/File system' service
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: Unable to delete service using curl 'XDELTE' on Nagios X

Post by mbellerue »

It's probably getting hung up because the service_description isn't URL encoded. Try this.

Code: Select all

curl -XDELETE "https://<Nagios xi Host Name>/nagiosxi/api/v1/config/service?apikey=tBNRmsqitghiurFNECXKOu7RjkI6AEOX7p8egoCQKvelfSoSLmCvAB&pretty=1&host_name=testapihost&service_description=Disk%20Usage%20on%20%2Fusr%2Flocal&applyconfig=1" -k
Also, if that does the trick, this site can help out a ton when working with curl and APIs.
https://www.url-encode-decode.com/
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
rthomas7
Posts: 5
Joined: Thu Mar 07, 2019 7:13 am

Re: Unable to delete service using curl 'XDELTE' on Nagios X

Post by rthomas7 »

mbellerue wrote:It's probably getting hung up because the service_description isn't URL encoded. Try this.

Code: Select all

curl -XDELETE "https://<Nagios xi Host Name>/nagiosxi/api/v1/config/service?apikey=tBNRmsqitghiurFNECXKOu7RjkI6AEOX7p8egoCQKvelfSoSLmCvAB&pretty=1&host_name=testapihost&service_description=Disk%20Usage%20on%20%2Fusr%2Flocal&applyconfig=1" -k
Also, if that does the trick, this site can help out a ton when working with curl and APIs.
https://www.url-encode-decode.com/
rthomas7
Posts: 5
Joined: Thu Mar 07, 2019 7:13 am

Re: Unable to delete service using curl 'XDELTE' on Nagios X

Post by rthomas7 »

Thank you very much indeed!. That looks to have done the trick. So, if there is no character or word in the square brackets after "failed", does it mean there was/is no error?

{
"success": "Removed services from the system. Config applied, Nagios Core was restarted.",
"services": [
"testapihost - Disk Usage on \/var\/tmp"
],
"failed": [

]
}
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: Unable to delete service using curl 'XDELTE' on Nagios X

Post by scottwilkerson »

I see there is a ticket with the same issue.

This will be continued in the ticket

Locking thread
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart