API call returns recordcount = 0

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
ibnetworking
Posts: 19
Joined: Mon Jan 16, 2017 4:32 am

API call returns recordcount = 0

Post 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)
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: API call returns recordcount = 0

Post 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?
Former Nagios employee
https://www.mcapra.com/
ibnetworking
Posts: 19
Joined: Mon Jan 16, 2017 4:32 am

Re: API call returns recordcount = 0

Post 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?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: API call returns recordcount = 0

Post 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.
Former Nagios employee
https://www.mcapra.com/
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: API call returns recordcount = 0

Post by dwhitfield »

Did @mcapra's post help you? Please let us know if you have any additional questions.
Locked