API call does not return all hosts.

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
amit.ahuja
Posts: 113
Joined: Fri May 15, 2015 8:20 am

API call does not return all hosts.

Post 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.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: API call does not return all hosts.

Post by rkennedy »

Can you show us the call you were making as well as the output? Also, what version of XI are you running?
Former Nagios Employee
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Re: API call does not return all hosts.

Post 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
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: API call does not return all hosts.

Post 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?
Former Nagios Employee
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Re: API call does not return all hosts.

Post 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
You do not have the required permissions to view the files attached to this post.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: API call does not return all hosts.

Post 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.
Former Nagios Employee
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Re: API call does not return all hosts.

Post by haile711 »

rkennedy,

That did it, thanks for helping!!!
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: API call does not return all hosts.

Post by mcapra »

Is it alright if we lock this thread and mark the issue as resolved?
Former Nagios employee
https://www.mcapra.com/
haile711
Posts: 197
Joined: Thu May 28, 2015 7:36 am

Re: API call does not return all hosts.

Post by haile711 »

mcapra,

Please do, thxs!
Locked