delete host through api

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
sib
Posts: 111
Joined: Thu Dec 11, 2014 8:06 am

delete host through api

Post by sib »

Hi

I can not delete a host through the new REST API (Nagios XI 5.2.1)

Code: Select all

# curl -k -XDELETE "https://lbnss22/nagiosxi/api/v1/config/host?apikey=key&host_name=lbnss01"
{
    "error": "Host cannot be deleted using this method. Must be deleted through the CCM."
}
Does not make sense to have to delete it in CCM as I want to automate it.

best
Chris
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: delete host through api

Post by lmiltchev »

Chris, does the host have any services or any other dependencies (i.e. there are host dependencies, the host is added to a hostgroup, etc.)? Can you go to the CCM->Hosts, click on the "Relationship Info" button next to the host and show us the output?
Be sure to check out our Knowledgebase for helpful articles and solutions!
sib
Posts: 111
Joined: Thu Dec 11, 2014 8:06 am

Re: delete host through api

Post by sib »

Hi

There is dependencies to various hostgroups

Code: Select all

Items labeled as: 'Dependent relationships' will prohibit deletion
Object ID: 120 of table tbl_host:
Relation to Hostgroups, entry: devua
Relation to Hostgroups, entry: all
Relation to Hostgroups, entry: centrify
Relation to Hostgroups, entry: patching-G3-prod-zurich
Relation to Hostgroups, entry: rhel5
Relation to Hostgroups, entry: rhel6
Relation to Hostgroups, entry: physical_dev
Relation to Hostgroups, entry: bisnet
Relation to Hostgroups, entry: zurich
Relation to Hostgroups, entry: nomonitor
Relation to Hosttemplates, entry: BIS_dev_host
I was hoping that it can resolve the dependencies by just removing the host from each hostgroup. I can resolve them before trying to delete the host.
Still I think the error message is too generic. It should return more useful information such as there is dependencies and maybe even include them into the return message.

best
Chris
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: delete host through api

Post by lmiltchev »

This is strange - I don't see 'Dependent relationship' in the output. See an example of a 'Dependent relationship' that will prohibit deletion (text in red):
example01.PNG
The deletion of your host should have worked. I will do some more digging into it. It is possible that this is a bug.
You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked