Got a couple of questions that I'm sure someone has solved before (so I don't have to re-invent).
We currently have an AWS account where we spin up and burn down tens of VMs every day. Most of the new hosts need to be added to Nagios and most of the VMs burned down need to be removed from Nagios. Currently, the way we've been adding the hosts is to bulk host clone and import and removing them is a pain in the a$$ (delete the services, then delete the hosts).
I see in the new version of Nagios, and we've successfully added hosts with the REST API (adding services is just as easy, but adding each service individually sucks too), but is there an EASY way to have all the services removed from the host without having to call the REST API for each and every service on that host?
Nagios XI REST API questions
Re: Nagios XI REST API questions
Removing all services from a host in "one go" is not possible via the REST API yet. According to our developers, this functionality could be added later on.
Then you will be left with a host with no services. Did this help?
For the time being, maybe you can try something like this:if you had stored the host/service names of items when you added them via the api you could just loop through and delete them all
with a single api command each
Code: Select all
cat /dev/null > /usr/local/nagios/etc/services/<your config>.cfg
cd /usr/local/nagiosxi/scripts
./reconfigure_nagios.shBe sure to check out our Knowledgebase for helpful articles and solutions!
Re: Nagios XI REST API questions
Doing it that way may be much faster. I'll have to try that.
Wondering if I could do that in conjunction with removing the server (and setting applyconfig=1) without having to reconfigure nagios first.
Wondering if I could do that in conjunction with removing the server (and setting applyconfig=1) without having to reconfigure nagios first.
-
krobertson71
- Posts: 444
- Joined: Tue Feb 11, 2014 10:16 pm
Re: Nagios XI REST API questions
We just started wrapping all the api curl call in a bash script. Of course this is just for our baseline setup. Any other added checks would have to be removed separately.
Re: Nagios XI REST API questions
I have to take my previous post back. I forgot to include a command to move the config from "services" to the "import" directory. In any case, this wouldn't work... I played with this a bit, and results were discouraging. 
I suppose you will need to delete one service at a time or create some kind of custom script that will loop through all of the services.
I suppose you will need to delete one service at a time or create some kind of custom script that will loop through all of the services.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Nagios XI REST API questions
Ergh... It just shouldn't be this painful.lmiltchev wrote:I have to take my previous post back. I forgot to include a command to move the config from "services" to the "import" directory. In any case, this wouldn't work... I played with this a bit, and results were discouraging.
I suppose you will need to delete one service at a time or create some kind of custom script that will loop through all of the services.
Do you know if anyone is working to add this to the REST API stack?
Re: Nagios XI REST API questions
I filed an internal feature request (TASK ID 8020) for adding this functionality. Thank you!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Nagios XI REST API questions
Thank you VERY much!lmiltchev wrote:I filed an internal feature request (TASK ID 8020) for adding this functionality. Thank you!
Re: Nagios XI REST API questions
You are welcome!
highness, I will be locking this topic now. I you want me to unlock it in the future, just PM me. Thanks!
highness, I will be locking this topic now. I you want me to unlock it in the future, just PM me. Thanks!
Be sure to check out our Knowledgebase for helpful articles and solutions!