Page 1 of 1

API call returns recordcount = 0

Posted: Tue Apr 25, 2017 6:13 am
by ibnetworking
Hi guys,

we're having a strange issue while calling /nagiosxi/api/v1/objects/hostgroup
When we're calling via curl, it returns the objects without an issue, but when calling it within a python script (w/ requests), it returns recordcount = 0 (when we have over 25).

Furthermore, when we remove objects.cache and objects.precache (which are both around 9 mb) , it works more than usual, but still returns recordcount = 0 sometimes.
We tried increasing php values (like memory_limit) to no avail.

Do you have any idea why this is happening? It is extremely strange that nagios returns recordcount = 0 for a call from a script, and recordcount = 25 when calling via curl.

Another issue we have is that /nagiosxi/api/v1/objects/service returns inconsistent results almost every run. (hosts missing, checks missing, etc)

Re: API call returns recordcount = 0

Posted: Tue Apr 25, 2017 11:45 am
by mcapra
Can you show us the curl command VS what your Python is running? It might be useful in determining exactly where the problem is.
ibnetworking wrote: Another issue we have is that /nagiosxi/api/v1/objects/service returns inconsistent results almost every run. (hosts missing, checks missing, etc)
Do you have any automation scripts working in the background currently? Or anything that would alter the state of the nagios database?

Re: API call returns recordcount = 0

Posted: Wed Apr 26, 2017 6:16 am
by ibnetworking
Hi,

this was a result of running reconfigure_nagios.sh and asking for list of services via API too fast, where nagios didn't managed to load all 10k checks from the database.
This was resolved by time.sleep(15).

It would very helpful to get the reply to the API call once the backend is done reconfiguring, not when the call was sent. Have you planned on adding this feature?

Re: API call returns recordcount = 0

Posted: Wed Apr 26, 2017 10:10 am
by mcapra
An issue has already been raised internally from a separate customer with the same issue, so you're not the only one to have been inconvenienced by this.
ibnetworking wrote: It would very helpful to get the reply to the API call once the backend is done reconfiguring, not when the call was sent. Have you planned on adding this feature?
That's one solution, but changes with Core 5 may make this unnecessary. It's on our radar for sure, though.

Re: API call returns recordcount = 0

Posted: Thu May 25, 2017 9:34 am
by dwhitfield
Did @mcapra's post help you? Please let us know if you have any additional questions.