How to Delete Host Dependencies with CLI

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
gregbeyer
Posts: 181
Joined: Fri Sep 11, 2020 2:13 pm

How to Delete Host Dependencies with CLI

Post by gregbeyer »

I mistakenly created ~114K host dependencies when using the API to import hosts. I've correcting the script that erroneously included the dependencies directive in the first place. But I have a mess -- 114K dependencies to remove. The XI CCM chokes at selecting and deleting more than 200 at a time. There must be a way, via CLI, to accomplish the same. Suggestions?
jsimon
Posts: 343
Joined: Wed Aug 23, 2023 11:27 am

Re: How to Delete Host Dependencies with CLI

Post by jsimon »

Hi Greg,

I don't believe there's a way to remove Host Dependencies with the API, but you should be able to revert to an older CCM config snapshot from before you made this change, which should fully revert you and let you rerun your fixed script.

It is possible that we have slightly crossed wires, however. Looking at the API reference, it doesn't seem like you should be able to add specifically "Host Dependencies" with an API command, so I'm wondering if what happened is that you added the parent directive, rather than a dependency. If so, you should be able to fix this by rerunning the PUT commands that created those hosts, but with an empty "Parent" directive, which should overwrite those hosts without the parent relationship. If this assumption is correct, the API should be able to fix this for you. I'd recommend testing this in small batches at first, to make sure you're getting what you want out of it. Otherwise I'd stick with reverting to an older snapshot, which may be less work in any case.

Hopefully that fixes this for you!
gregbeyer
Posts: 181
Joined: Fri Sep 11, 2020 2:13 pm

Re: How to Delete Host Dependencies with CLI

Post by gregbeyer »

Thanks jsimon, I haven't had to use snapshots before to get me me out of trouble, and that worked - mess reverted.

What I meant was I used the API to import a list of hosts. Unfortunately, the script that queried our CMDB for creation of that list included dependent_host_name. So remove that from script and we'll be good.
jsimon
Posts: 343
Joined: Wed Aug 23, 2023 11:27 am

Re: How to Delete Host Dependencies with CLI

Post by jsimon »

Glad you were able to get back to a workable state! I'm gonna close this thread and make an internal note about improving documentation for creating dependencies with the API.
Locked