Page 1 of 1

Nagios XI Service Status Rest API - No Data Returning

Posted: Mon Apr 06, 2020 8:17 am
by rgangavarapu
Hi,

We have an internal application that fetches Service Status by using the list of Host Names and shows the results using Nagios XI Rest endpoints.

If all hosts are having at least service, then Services Data is coming, But if any of the Hosts are not having at least one service, then Services Data is NOT coming instead we are getting empty Service Status.

URL: http://nagios.com/nagiosxi/api/v1/objec ... OST2,HOST3
HOST1: No Services
HOST2: Disk Check
HOST3: Memory Check

Actual: Empty Service Status List
Expected: Two Service Status List

Could anyone please help me.

Re: Nagios XI Service Status Rest API - No Data Returning

Posted: Mon Apr 06, 2020 4:57 pm
by jbrunkow
Can you please specify what you are referring to for the syntax near the end of that link? Is that how your internal application would handle iterating through hosts?

Also, just so we understand the issue correctly if the script works as long as all hosts have an associated service, but if one host does not, no data is being retrieved by the API call? Is this correct?

It may also be helpful for you to send us your internal script in a private message.

Re: Nagios XI Service Status Rest API - No Data Returning

Posted: Mon Apr 06, 2020 7:30 pm
by rgangavarapu
We are not passing anything at the end of the link. I have given the URL (added space after the http to ensure it won't convert to URL in the post)

URL: http:// nagios.com/nagiosxi/api/v1/objects/servicestatus?apikey=XXXXXXAPI_KEYXXXXXX&host_name=in:HOST1,HOST2,HOST3

Yes, No Data is being retried by API if any one of the hosts doesn't have any data. But if the NO service Host is at the end of the list (last Host), then data is being retried.
In our case, First Host is having NO service and NO data is being retried.

We are using "check_http" (binary script) of the Nagios Plugins to validate the Application Status. But in the case of Database servers or Utility, we don't have any applications running, so there is no service configured.

We do get the list of hosts using another Rest Endpoint by using Host Group and pass the list (comma separated) to Service Status Rest Endpoint to the services and their statuses.

Re: Nagios XI Service Status Rest API - No Data Returning

Posted: Tue Apr 07, 2020 1:42 pm
by jbrunkow
The API seems to be working for multiple hosts on our test instance, even when one of those does not have a service associated with it. It could be a bug in a particular version. What version of Nagios XI are you running?

There is another forum topic that looks slightly similar, and they found that the problem was related to a limitation in PHP do to the size of the API call. I would recommend following the guide to optimize the PHP settings in XI.
Nagios XI - Optimizing The PHP Settings File

Re: Nagios XI Service Status Rest API - No Data Returning

Posted: Wed Apr 08, 2020 6:19 am
by rgangavarapu
We have made php.ini changes as suggested at https://support.nagios.com/kb/article/n ... e-611.html and we are validating the API Results.

Nagios XI Version: 5.4.10

Current /etc/php.ini file changes are listed below

max_input_vars => 5000
memory_limit => 1024M
max_execution_time => 90
max_input_time => 90

Re: Nagios XI Service Status Rest API - No Data Returning

Posted: Wed Apr 08, 2020 9:56 am
by lmiltchev
You are using an old version of Nagios XI. I haven't been able to recreate the issue in the latest version of XI (5.6.13), so I am pretty confident that the issue has been resolved.

I would recommend that you upgrade your Nagios XI instance to the latest in order to fix the issue.