Page 1 of 1
Can I remove host from service group using API
Posted: Tue Jan 19, 2021 3:16 pm
by JosephH
I am using Nagios XI 5.7.4.
Looks like there will be an issue if I remove a host using API without checking if this host is a member of servicegroup. How can I remove this host from a servicegroup using API? or Is there a work around to complete the task programmatically using API?
Thanks
Re: Can I remove host from service group using API
Posted: Wed Jan 20, 2021 4:14 pm
by ssax
What error are you getting when you do this? Or is it an error when you're applying configuration? Either way, post the full error output you see.
I labbed this up in XI 5.7.4 with a host that has services in a hostgroup and it deleted the host and all services properly.
You may need to do this after deleting the host:
Please go to Configure > Core Config Manager > Tools > Config File Management:
- Click the Delete Files button (don't worry, it's safe, they will be rewritten)
- Then click the Write Configs button
- Then try to apply configuration
Please PM me a copy of your profile.zip, you can download it from Admin > System Profile by clicking the Download Profile button.
If you're unable to generate the the profile through the web interface, please try generating it from the command line by running these commands as root:
Code: Select all
rm -rf /usr/local/nagiosxi/var/components/profile*
/usr/local/nagiosxi/scripts/components/getprofile.sh SUPPORT
Then send me the resulting
/usr/local/nagiosxi/var/components/profile.zip file.
If the profile script fails, please include the ENTIRE output.
Re: Can I remove host from service group using API
Posted: Thu Jan 21, 2021 10:07 am
by JosephH
Hi ssax,
Thank you for your post. You are right that I can remove host from service group using API. What I found out later is this: when you look at the host configuration, click the action column relationships icon, then you will see Object relationships Dependent relationships denoted by %, look the Services tab (which denoted by %), if there any services listed, click it and look at the Service Management page, check Manage Hosts(you can see this host listed there) and/or has Managed Host Groups listed, and you try to delete this host will generate the following error:
---------------------------
Read main config file okay...
Error: Could not find any host matching 'hostname' (config file 'xxxxxx/services/Filesystem-xxxxx.cfg', starting on line 16)
Error: Failed to expand host list 'hostname' for service 'Filesystem /xyz Percent Used' (xxxxxxx/services/Filesystem-xxxxx.cfg:16)
Error processing object config files!
---------------------------
Now my question is how do I delete this host with API correctly without any error? Is it possible using API?
Thanks
Joseph
Re: Can I remove host from service group using API
Posted: Thu Jan 21, 2021 7:39 pm
by ssax
I'm still not able to replicate this. I'm able to delete a host with services attached directly to the host and when the services are attached to a hostgroup that the host is a member of (I created both types of services and it removed the host from both properly).
Please create a ticket for this and include a link back to this forum thread so we can get a remote session setup to debug further:
https://support.nagios.com/tickets/
Thank you!
Re: Can I remove host from service group using API
Posted: Tue Jan 26, 2021 7:07 pm
by ssax
Locking thread, ticket received, we will continue support through the ticket.