Page 1 of 1

Nagios REST API issue

Posted: Mon Dec 10, 2018 5:10 am
by gpanou
Hello,

I am trying to utilize the REST API to get usage stats.

I have run into a problem specifically for the statushistory call, whenever I try the example from the objects reference page with only a starttime parameter I get an empty json as response (No errors or any wearnings). The result is supposed to be the data until now.

Now, if I add an endtime parameter with a date prior to 4-12-2018 18:21:00 (EET - I add it as the equivalent of that datetime in seconds) I get a response with the data as expected. I pretty sure the first time I tried the /nagiosxi/help/api-object-reference.php#building-queries examples I could sometimes get the result with just the starttime parameter. Wierdest thing is, I think the date I mentioned might be the first time I used the examples.

The hostavailability call works fine - I am guessing other REST components work fine as well.

Any ideas why this could be happening or actions I can do to overcome this issue will be appreciated. I am actually accessing the API with Python, but have tested with my browser, and my code, and curl and the result is the same.

My clients expect a weekly report so I am in need to get a workaround as sooner as possible.

George Panou
Algosystems SA

Re: Nagios REST API issue

Posted: Mon Dec 10, 2018 5:45 pm
by npolovenko
@gpanou, What timestamp for the start time did you use? Was it some time in April this year? -> (4-12-2018)
This means the API report was supposed to return 8 months worth of data(since when you don't specify the end time Nagios defaults to "now" value). That kind of report may be too large for the API.

Re: Nagios REST API issue

Posted: Tue Dec 11, 2018 3:50 am
by gpanou
Thanks for the reply, the date is 4 Dec 2018 (European format). I am testing it with the browser examples as well so even the now timestamp in seconds doesn't work.

For example:
http://x.x.x.x/nagiosxi/api/v1/objects/ ... lOTJqNlm8V

Re: Nagios REST API issue

Posted: Tue Dec 11, 2018 4:02 am
by gpanou
Since I am working on a production environment, is there a single Nagios service related to the REST API I could try restarting?

Re: Nagios REST API issue

Posted: Tue Dec 11, 2018 5:34 am
by gpanou
In any case my API call requests less than a week of data

Re: Nagios REST API issue

Posted: Tue Dec 11, 2018 12:23 pm
by npolovenko
@gpanou, I see. Can you open the XI web interface, go to Reports and generate a state history report from Tue, 04 Dec 2018 till now and let me know if you see any data in the report?

Could you also send in your system profile?
To send us your system profile. Login to the Nagios XI GUI using a web browser.
Click the "Admin" > "System Profile" Menu
Click the "Download Profile" button
Save the profile.zip file and send it to me in a personal message.
After you send the profile please post something in this thread to bring it back up in the support queue.

Re: Nagios REST API issue

Posted: Tue Dec 11, 2018 2:31 pm
by gpanou
npolovenko wrote:@gpanou, I see. Can you open the XI web interface, go to Reports and generate a state history report from Tue, 04 Dec 2018 till now and let me know if you see any data in the report?

Could you also send in your system profile?
To send us your system profile. Login to the Nagios XI GUI using a web browser.
Click the "Admin" > "System Profile" Menu
Click the "Download Profile" button
Save the profile.zip file and send it to me in a personal message.
After you send the profile please post something in this thread to bring it back up in the support queue.
The state history report is 29 pages of data that seems OK, there is data since 4 Dec until Now.

I sent you the profile via pm.

Re: Nagios REST API issue

Posted: Tue Dec 11, 2018 3:32 pm
by npolovenko
@gpanou, I see some indications of crashed PHP processes because there is no sufficient memory.
Please open the /etc/php.ini file and increase the "memory_limit" to 512M.
Then restart apache with service httpd restart and try your API command one more time.

Re: Nagios REST API issue

Posted: Wed Dec 12, 2018 3:10 am
by gpanou
That did the trick!
Thanks a lot for your help and for the quick response.

Re: Nagios REST API issue

Posted: Thu Dec 13, 2018 1:56 pm
by npolovenko
@gpanou , You're welcome!