Multiple calls to API with applyconfig=1

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

Multiple calls to API with applyconfig=1

Post by highness »

I'm working to automate the addition of hosts in Nagios when we stand them up in Ansible. While I was testing the scripts in development, I called the API several times with the applyconfig=1 parameter by mistake.

Because it was in the test environment, it wasn't a big deal, but was curious to find out where these requests are queued up (and maybe my script could check to ensure that subsequent apply configs aren't done)?
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Multiple calls to API with applyconfig=1

Post by dwhitfield »

There is work going on in the API that should help you in this endeavor. Unfortunately, I don't have an ETA on that.

My major concern with limiting apply configs is that what if you are spinning up two different machines and they both need to run apply config. You need them both to run. Maybe I'm misunderstanding exactly what you want to do though.

It's possible you could just "queue up" the apply config in a variable in your script and just have it run once when the script exits.
highness
Posts: 192
Joined: Thu May 01, 2014 4:25 pm

Re: Multiple calls to API with applyconfig=1

Post by highness »

dwhitfield wrote:My major concern with limiting apply configs is that what if you are spinning up two different machines and they both need to run apply config. You need them both to run. Maybe I'm misunderstanding exactly what you want to do though.
My script typically does wait until the last host has been added before doing an applyconfig=1, but in this case, we had someone feed each host in individually instead of a feeding in the group of hosts.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Multiple calls to API with applyconfig=1

Post by tgriep »

Are you asking if there is an API call to see if the system needs an apply config ran or if one is in the queue?
If so, that function is not in the API currently, your application would have to keep track of that for you.
Does that answer your question?
Be sure to check out our Knowledgebase for helpful articles and solutions!
highness
Posts: 192
Joined: Thu May 01, 2014 4:25 pm

Re: Multiple calls to API with applyconfig=1

Post by highness »

tgriep wrote:Are you asking if there is an API call to see if the system needs an apply config ran or if one is in the queue?
If so, that function is not in the API currently, your application would have to keep track of that for you.
Not really - wanting to know where it queues those requests up at. Are they added to the ipcs queue? If so, then looking for them would be a lost cause.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Multiple calls to API with applyconfig=1

Post by tgriep »

From what I was told, they do not queue up. If you create a host or service check using the API but do not apply it, those entries are added to the nagiosql database as Not Applied configs, every call creates an entry.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked