Page 1 of 1
Multiple calls to API with applyconfig=1
Posted: Thu May 11, 2017 4:28 pm
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)?
Re: Multiple calls to API with applyconfig=1
Posted: Thu May 11, 2017 4:41 pm
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.
Re: Multiple calls to API with applyconfig=1
Posted: Mon May 15, 2017 9:45 am
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.
Re: Multiple calls to API with applyconfig=1
Posted: Mon May 15, 2017 1:47 pm
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?
Re: Multiple calls to API with applyconfig=1
Posted: Mon May 15, 2017 2:40 pm
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.
Re: Multiple calls to API with applyconfig=1
Posted: Mon May 15, 2017 3:46 pm
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.