Delete service using REST API error on XI version 5.6.5
Delete service using REST API error on XI version 5.6.5
Trying to delete services in pending status using Rest API got the following error:
{
"error": "Could not remove services. Failed services may not exist.",
"services": [],
"failed": ["servername - Virtual Memory Usage"]
}
Here are what I found out:
1. all the services in pending status are configured passive
2. I can use REST API to get all the services back for this host
3. In CCM, there is no services listed under this service configuration name: servername.cfg
Any help is greatly appreciated.
Thanks
Joseph
{
"error": "Could not remove services. Failed services may not exist.",
"services": [],
"failed": ["servername - Virtual Memory Usage"]
}
Here are what I found out:
1. all the services in pending status are configured passive
2. I can use REST API to get all the services back for this host
3. In CCM, there is no services listed under this service configuration name: servername.cfg
Any help is greatly appreciated.
Thanks
Joseph
Re: Delete service using REST API error on XI version 5.6.5
Can you show us the actual REST API command that you used, and the service config?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Delete service using REST API error on XI version 5.6.5
Here is the command to get the service status from SOAP UI, which returns 1 record:
Here is the command I used from SOAP UI for deleting service:(and got the error)
and the service configure file for this host: (no Virtual Memory Usage, only Ping)
define service {
host_name hostname
service_description Ping
check_command check-host-alive
max_check_attempts 5
check_interval 5
retry_interval 1
check_period xi_timeperiod_24x7
notification_interval 60
notification_period xi_timeperiod_24x7
notifications_enabled 0
contacts xxxx
_xiwizard linux_snmp
register 1
}
###############################################################################
#
# Services configuration file
#
# END OF FILE
#
###############################################################################
Code: Select all
https://linuxserver/nagiosxi/api/v1/objects/servicestatus?apikey=ApiKey&pretty=1&host_name=hostname&has_been_checked=0&name=virtual%20memory%20usageCode: Select all
https://linuxserver/nagiosxi/api/v1/config/service?apikey=ApiKey&pretty=1&host_name=hostname&service_description=Virtual Memory Usagedefine service {
host_name hostname
service_description Ping
check_command check-host-alive
max_check_attempts 5
check_interval 5
retry_interval 1
check_period xi_timeperiod_24x7
notification_interval 60
notification_period xi_timeperiod_24x7
notifications_enabled 0
contacts xxxx
_xiwizard linux_snmp
register 1
}
###############################################################################
#
# Services configuration file
#
# END OF FILE
#
###############################################################################
Re: Delete service using REST API error on XI version 5.6.5
Are you applying configuration? Add "&applyconfig=1" to your command - the service won't get deleted, until you apply configuration.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Delete service using REST API error on XI version 5.6.5
I believe it is error-ed out before running "&applyconfig=1"
Re: Delete service using REST API error on XI version 5.6.5
So, was the service present, then deleted via the REST API, regardless of the error shown after running the delete command? You said that you could only see "Ping" service on this host, so the "Virtual Memory Usage" must have been deleted.
When you said:
I was hoping to see the REST API command, run from the command line, along with the output of it...
Example:
Did you use this:
or this:
- can you clarify?
When you said:
did you mean you used this tool: https://www.soapui.org/?Here is the command I used from SOAP UI...
I was hoping to see the REST API command, run from the command line, along with the output of it...
Example:
Code: Select all
[root@main-nagios-xi ~]# curl -XDELETE "http://x.x.x.x/nagiosxi/api/v1/config/service?apikey=xxx&pretty=1&host_name=testapihost&service_description=PING&applyconfig=1"
{
"success": "Removed services from the system. Config applied, Nagios Core was restarted.",
"services": [
"testapihost - PING"
],
"failed": [
]
}Code: Select all
https://linuxserver/nagiosxi/api/v1/config/service?apikey=ApiKey&pretty=1&host_name=hostname&service_description=Virtual Memory UsageCode: Select all
https://linuxserver/nagiosxi/api/v1/config/service?apikey=ApiKey&pretty=1&host_name=hostname&service_description=Virtual%20Memory%20UsageYou are correct. Can you apply configuration by running the command below?I believe it is error-ed out before running "&applyconfig=1"
Code: Select all
curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/system/applyconfig?apikey=xxx"Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Delete service using REST API error on XI version 5.6.5
Hi lmiltchev,
Thank you so much for willing to help.
1. I used SoapUI by SMART BARE, a window desktop console application. it is from https://www.soapui.org/
2. Even before deleting the service, the service configuration file only have Ping defined, we define all others using passive. And all the passive checks shown on the service status panel in pending status. We use get service status API can get this service info back.
3. I ran the curl command as below and error-ed.
curl -k -XDELETE "https://linuxserver/nagiosxi/api/v1/con ... lyconfig=1"
{
"error": "Could not find a unique id for this service."
}
4. Yes, I can run the following command
curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/system/a ... apikey=xxx"
Thank you,
Joseph
Thank you so much for willing to help.
1. I used SoapUI by SMART BARE, a window desktop console application. it is from https://www.soapui.org/
2. Even before deleting the service, the service configuration file only have Ping defined, we define all others using passive. And all the passive checks shown on the service status panel in pending status. We use get service status API can get this service info back.
3. I ran the curl command as below and error-ed.
curl -k -XDELETE "https://linuxserver/nagiosxi/api/v1/con ... lyconfig=1"
{
"error": "Could not find a unique id for this service."
}
4. Yes, I can run the following command
curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/system/a ... apikey=xxx"
Thank you,
Joseph
Re: Delete service using REST API error on XI version 5.6.5
Do you see the service in the GUI?
Can you find it now by running the command below?
You said that you used these commands:
Do you have two different services - "virtual memory usage" and "Virtual Memory Usage", or you have one (this is a typo)?
Do you have any errors / crashed tables in the db?
or
Are you seeing the same issue after restarting services?
Can you find it now by running the command below?
Code: Select all
curl -XGET "http://xxx/nagiosxi/api/v1/objects/servicestatus?apikey=xxx&pretty=1&host_name=hostname&has_been_checked=0&name=virtual%20memory%20usage"Code: Select all
https://linuxserver/nagiosxi/api/v1/objects/servicestatus?apikey=ApiKey&pretty=1&host_name=hostname&has_been_checked=0&name=virtual%20memory%20usageCode: Select all
https://linuxserver/nagiosxi/api/v1/config/service?apikey=ApiKey&pretty=1&host_name=hostname&service_description=Virtual Memory UsageDo you have any errors / crashed tables in the db?
Code: Select all
tail /var/log/mysqld.logCode: Select all
tail /var/log/mariadb/mariadb/logCode: Select all
service nagios stop
service ndo2db retart
service nagios startBe sure to check out our Knowledgebase for helpful articles and solutions!
Re: Delete service using REST API error on XI version 5.6.5
Hi lmiltchev,
To answer your questions:
1. Do you see the service in the GUI?
Yes. I can see it from service status for this host in Pending status.
2. Can you find it now by running the command below?
Yes. I got the info back by running the following command:
https://linuxserver/nagiosxi/api/v1/obj ... ry%20usage
3. Do you have two different services - "virtual memory usage" and "Virtual Memory Usage", or you have one (this is a typo)?
I only have one service named "Virtual Memory Usage". It was a typo.
4. Do you have any errors / crashed tables in the db?
I do not have permission to read this file "/var/log/mariadb/mariadb/log". I may ask admin to take a look.
5. Are you seeing the same issue after restarting services?
I believe so since we restarted few times. I will check with Admin to be sure.
Thanks
Joseph
To answer your questions:
1. Do you see the service in the GUI?
Yes. I can see it from service status for this host in Pending status.
2. Can you find it now by running the command below?
Yes. I got the info back by running the following command:
https://linuxserver/nagiosxi/api/v1/obj ... ry%20usage
3. Do you have two different services - "virtual memory usage" and "Virtual Memory Usage", or you have one (this is a typo)?
I only have one service named "Virtual Memory Usage". It was a typo.
4. Do you have any errors / crashed tables in the db?
I do not have permission to read this file "/var/log/mariadb/mariadb/log". I may ask admin to take a look.
5. Are you seeing the same issue after restarting services?
I believe so since we restarted few times. I will check with Admin to be sure.
Thanks
Joseph
Re: Delete service using REST API error on XI version 5.6.5
Is the "Virtual Memory Usage" service added to multiple hosts or a hostgroup?
Be sure to check out our Knowledgebase for helpful articles and solutions!