Nagios XI REST API questions

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
highness
Posts: 192
Joined: Thu May 01, 2014 4:25 pm

Nagios XI REST API questions

Post by highness »

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?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Nagios XI REST API questions

Post by lmiltchev »

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.
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
For the time being, maybe you can try something like this:

Code: Select all

cat /dev/null > /usr/local/nagios/etc/services/<your config>.cfg
cd /usr/local/nagiosxi/scripts
./reconfigure_nagios.sh
Then you will be left with a host with no services. Did this help?
Be sure to check out our Knowledgebase for helpful articles and solutions!
highness
Posts: 192
Joined: Thu May 01, 2014 4:25 pm

Re: Nagios XI REST API questions

Post by highness »

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.
krobertson71
Posts: 444
Joined: Tue Feb 11, 2014 10:16 pm

Re: Nagios XI REST API questions

Post by krobertson71 »

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.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Nagios XI REST API questions

Post by lmiltchev »

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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
highness
Posts: 192
Joined: Thu May 01, 2014 4:25 pm

Re: Nagios XI REST API questions

Post by highness »

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.
Ergh... It just shouldn't be this painful.

Do you know if anyone is working to add this to the REST API stack?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Nagios XI REST API questions

Post by lmiltchev »

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!
highness
Posts: 192
Joined: Thu May 01, 2014 4:25 pm

Re: Nagios XI REST API questions

Post by highness »

lmiltchev wrote:I filed an internal feature request (TASK ID 8020) for adding this functionality. Thank you!
Thank you VERY much!
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Nagios XI REST API questions

Post by lmiltchev »

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!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked