can't decommission host via api
can't decommission host via api
hello i am trying to use the rest api to remove a host from nagiosxi 5.2.3 using this command
curl -XDELETE "https://nagios/nagiosxi/api/v1/config/h ... lyconfig=1"
and i get this error:
"error": "Host cannot be deleted using this method. Must be deleted through the CCM."
however there are no dependencies i can see that should blcok this:
Database Relationships for host:
lptls03.lifelock.ad
Items labeled as: 'Dependent relationships' will prohibit deletion
Object ID: 764 of table tbl_host:
Relation to Hostgroups, entry: prod-linux-servers
Relation to Hostgroups, entry: ncpa-agents
Relation to Hosttemplates, entry: ll_ncpa_host
Also, i need to know how to script disabling notification on a hosts and its services via the api, so that we don't have to applyconfig everytime we try to decommission a server. This causes a service disruption with our nagvis setup and we have this scheduled to happen daily.
Thanks,
curl -XDELETE "https://nagios/nagiosxi/api/v1/config/h ... lyconfig=1"
and i get this error:
"error": "Host cannot be deleted using this method. Must be deleted through the CCM."
however there are no dependencies i can see that should blcok this:
Database Relationships for host:
lptls03.lifelock.ad
Items labeled as: 'Dependent relationships' will prohibit deletion
Object ID: 764 of table tbl_host:
Relation to Hostgroups, entry: prod-linux-servers
Relation to Hostgroups, entry: ncpa-agents
Relation to Hosttemplates, entry: ll_ncpa_host
Also, i need to know how to script disabling notification on a hosts and its services via the api, so that we don't have to applyconfig everytime we try to decommission a server. This causes a service disruption with our nagvis setup and we have this scheduled to happen daily.
Thanks,
Re: can't decommission host via api
There is either a dependency, or possibly a bug that was fixed between 5.2.3 and 5.2.7. I just ran the exact command, on a newly created host on my machine, without issues. -
I do see a few bugs were fixed with the API between these versions as well.
As for disabling notifications, it's still going to require an apply configuration regardless.
Code: Select all
[root@localhost ~]# curl -XDELETE "http://192.168.4.223/nagiosxi/api/v1/config/host?apikey=58fvbk58&pretty=1&host_name=test5&applyconfig=1"
{
"success": "Removed test5 from the system. Config applied, Nagios Core was restarted."
}
As for disabling notifications, it's still going to require an apply configuration regardless.
Former Nagios Employee
Re: can't decommission host via api
i updated to 5.2.7 and it worked for a few days and now i am bback to the same error. here is the dependency list, there are none.
Items labeled as: 'Dependent relationships' will prohibit deletion
Object ID: 601 of table tbl_host:
Relation to Hostgroups, entry: dev-linux-servers
Relation to Hostgroups, entry: ncpa-agents
Relation to Hosttemplates, entry: ll_ncpa_host
curl -x https://proxy:3128 -k -XDELETE "https://nagiosxi.lifelock.com/nagiosxi/ ... t.fqdn.com"
{
"error": "Host cannot be deleted using this method. Must be deleted through the CCM."
}
Items labeled as: 'Dependent relationships' will prohibit deletion
Object ID: 601 of table tbl_host:
Relation to Hostgroups, entry: dev-linux-servers
Relation to Hostgroups, entry: ncpa-agents
Relation to Hosttemplates, entry: ll_ncpa_host
curl -x https://proxy:3128 -k -XDELETE "https://nagiosxi.lifelock.com/nagiosxi/ ... t.fqdn.com"
{
"error": "Host cannot be deleted using this method. Must be deleted through the CCM."
}
Re: can't decommission host via api
If the host didn't have any hostgroups added to it, you would be able to delete it via the REST API. I can confirm that this is a bug. You can delete a host with one or more hostgroups added to it in the CCM but when you try to delete the same host via the REST API, it errors out...
We will be filing an internal bug report shortly.
We will be filing an internal bug report shortly.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: can't decommission host via api
Just filed a bug report for this - TASK ID 8500 -
Were there any other questions, or may we lock this thread?
Were there any other questions, or may we lock this thread?
Be sure to check out the Knowledgebase for helpful articles and solutions!
Re: can't decommission host via api
ok so then the bug will be fixed in a later version and we will be able to do this?
Re: can't decommission host via api
That is correct, it should be fixed in a later version although I have zero details regarding a timeline as the FR was filed only a few hours ago.
Be sure to check out the Knowledgebase for helpful articles and solutions!
Re: can't decommission host via api
ok, is there a workaround to do this remotely? we have this built into our deocmmissioning process in our check_mk instance that we are migrating from and need to reproduce it in xi. can the cmd.cgi be used? i don't see any cmd_typ that supports deletion of a host. thanks,
Re: can't decommission host via api
You should be able to delete a host by running the following commands from the command line:
where you substitute "config name" with the actual config name.
For example, if you had a host config called "testapihostapply.cfg" in the "/usr/local/nagios/etc/hosts/" directory, you would run:
For more information on the automated host management, please review our documentation on the topic here:
https://assets.nagios.com/downloads/nag ... gement.pdf
Code: Select all
cd /usr/local/nagiosxi/scripts
./nagiosql_delete_host.php --host=<config name>
./reconfigure_nagios.shFor example, if you had a host config called "testapihostapply.cfg" in the "/usr/local/nagios/etc/hosts/" directory, you would run:
Code: Select all
./nagiosql_delete_host.php --host=testapihostapplyhttps://assets.nagios.com/downloads/nag ... gement.pdf
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: can't decommission host via api
right but we are trying to do this remotely from webservice without having to pass a key/pass to ssh to the box to run local commands.