We do not directly align hosts to any of our services, all services are aligned with hostgroups. How do I delete a service via the REST API? The call REQUIRES host_name based upon the documentation and what I could find in the php back end.
I currently have automations in place that will push new and updated services across our infrastructure as required, however I need to now have the ability to remove out dated services faster.
I found some posts from 2011 that said it was in progress ... I really hope it's done?
Service Delete API
Re: Service Delete API
Hi Nagios Team, any thoughts on this or should I open a ticket?
Re: Service Delete API
Use the endpoint config/service/<config_name>/<service_description> and you don't need to pass the hostname:
Code: Select all
curl -XDELETE "http://xi_ip/nagiosxi/api/v1/config/service/localhost/PING?apikey=apikey&pretty=1&service_description=PING&applyconfig=1"As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Service Delete API
I'm assuming the service description in the URL doesn't need to be there twice? I'll be testing this shortly.
Re: Service Delete API
Hmm something is wrong, it still doesn't appear to be working for me. I've got this deployed to a host because of testing however it won't delete when the URL is being used. I'm using a complicated service_description as it matches reality. The configname and description are being looked up from the host that it's attempting to delete the item from, the only manipulation to the name / description was making it URL friendly.
Doing DELETE to:https://XIHOST:443/nagiosxi/api/v1/conf ... PIGOESHERE :: with:null
Post Processing Output: {
"error": "Could not remove services. Failed services may not exist.",
"services": [
],
"failed": [
"Linux_Baseline - SomethingSomethig - __ Goes Here"
]
}
-----
Service Definition
define service {
host_name localhost
service_description SomethingSomethig - __ Goes Here
use <TEMPLATE Name>
check_command check_tcp!5693!!!!!!!
register 1
}
Doing DELETE to:https://XIHOST:443/nagiosxi/api/v1/conf ... PIGOESHERE :: with:null
Post Processing Output: {
"error": "Could not remove services. Failed services may not exist.",
"services": [
],
"failed": [
"Linux_Baseline - SomethingSomethig - __ Goes Here"
]
}
-----
Service Definition
define service {
host_name localhost
service_description SomethingSomethig - __ Goes Here
use <TEMPLATE Name>
check_command check_tcp!5693!!!!!!!
register 1
}
Re: Service Delete API
Try sending it with localhost instead of Linux_Baseline as the hostname, i.e. https://XIHOST:443/nagiosxi/api/v1/conf ... ]localhost[/u]/SomethingSomethig%20-%20__%20Goes%20Here?apikey=APIGOESHERE
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.
Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
Re: Service Delete API
Linux_Baseline is the confg_name in the monitor so I'm confused by that recommendation? There is no hostname part of the service definition.
Re: Service Delete API
Hey @dh0125e, it looks like I tested something incorrectly and this will not work. Sorry for the bad info. We can file a feature request for this though.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: Service Delete API
According to forum posts I found this was in the pipeline in 2011. Just confirming this has NOT been resolved? If not yes this needs to be an RFE.
Re: Service Delete API
I labbed it up as well and it will not work without a host_name being passed as you original found, in the previous examples they are still passing a host_name but it's being pulled from the URL (config/service/localhost/PING). Whatever you set in bold there will be the host_name.
I've created a request for development to add this as a feature:
FR: XI - API - config/service DELETE - Add the ability to delete services by config_name and service description for services that are assigned via hostgroups
Please keep in mind that the decision to implement the enhancement is at the discretion of our development team.
Thank you! Sorry for any confusion!
I've created a request for development to add this as a feature:
FR: XI - API - config/service DELETE - Add the ability to delete services by config_name and service description for services that are assigned via hostgroups
Please keep in mind that the decision to implement the enhancement is at the discretion of our development team.
Thank you! Sorry for any confusion!