Page 1 of 1
API call does not return all hosts.
Posted: Tue Jul 12, 2016 7:31 am
by amit.ahuja
Hi,
We were having some issue with the backend API in Nagios. One of own tools was using API call to get all of the hosts that were being monitored in Nagios. But, yesterday, one of the calls returned a JSON only contained part of the hosts. Does anyone have a solution for this issue?
Thanks.
Re: API call does not return all hosts.
Posted: Tue Jul 12, 2016 9:40 am
by rkennedy
Can you show us the call you were making as well as the output? Also, what version of XI are you running?
Re: API call does not return all hosts.
Posted: Tue Jul 12, 2016 1:04 pm
by haile711
rkennedy,
this is the call im making that have the same issue.
[url]http://nagios_server/nagiosxi/api/v1/objects/servicestatus?apikey=apikey&pretty=1[/url].
The page come up blank, but any other calls work.
Thanks
Re: API call does not return all hosts.
Posted: Tue Jul 12, 2016 1:09 pm
by rkennedy
Can you post your HTTP log files for us to look at?
Code: Select all
/var/log/httpd/error_log
/var/log/httpd/ssl_error_log
/var/log/httpd/access_log
/var/log/httpd/ssl_access_log
Additionally, what version of XI are you running?
Re: API call does not return all hosts.
Posted: Tue Jul 12, 2016 1:31 pm
by haile711
rkennedy,
current version: 5.2.3
I've attached the access_log and error_log but the other 2 it's empty
Thxs
Re: API call does not return all hosts.
Posted: Tue Jul 12, 2016 1:38 pm
by rkennedy
This error seems to be all over -
Code: Select all
[Tue Jul 12 02:22:07 2016] [error] [client 11.48.169.63] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 354 bytes) in /usr/local/nagiosxi/html/backend/includes/xml2json.php on line 243
Which I'm guessing is why you're seeing a blank page. Try changing your memory_limit setting from 128M to 256M in /etc/php.ini. Here is how mine currently looks -
Code: Select all
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 128M
After changing the memory_limit = 128M to memory_limit = 256M run a service httpd restart, and try to open the API once again.
Re: API call does not return all hosts.
Posted: Tue Jul 12, 2016 2:04 pm
by haile711
rkennedy,
That did it, thanks for helping!!!
Re: API call does not return all hosts.
Posted: Tue Jul 12, 2016 2:10 pm
by mcapra
Is it alright if we lock this thread and mark the issue as resolved?
Re: API call does not return all hosts.
Posted: Tue Jul 12, 2016 2:16 pm
by haile711
mcapra,
Please do, thxs!