API 500 Internal Server Error

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
meganwilliford
Posts: 101
Joined: Tue Aug 06, 2019 7:49 am

API 500 Internal Server Error

Post by meganwilliford »

We are getting a 500 internal server error for an API Object Reference on a few of our Nagios XI instances. However on the same Nagios XI instances other API Object References are available with no issues. Any ideas on why we wouldn't be able to reach the Objects Service API on some of the Nagios XI instances?

Nagios XI Host 1
500 Internal Server Error:
https://<nagios_host_1>/nagiosxi/api/v1/objects/service?apikey=X
Successful:
https://<nagios_host_1>/nagiosxi/api/v1/objects/statehistory?apikey=X

Nagios XI Host 2
Successful:
https://<nagios_host_2>/nagiosxi/api/v1/objects/service?apikey=X
Successful:
https://<nagios_host_2>/nagiosxi/api/v1/objects/statehistory?apikey=X
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: API 500 Internal Server Error

Post by ssax »

I'm wondering if you have some crashed tables...

Please send the output of these commands (as root):
- NOTE: You may need to adjust the -h 127.0.0.1, the -uroot, and -pnagiosxi in the first command if your DB is offloaded to another server and/or you've changed the root mysql password

Code: Select all

echo "SELECT table_name AS 'Table', round(((data_length + index_length) / 1024 / 1024), 2) 'Size in MB' FROM information_schema.TABLES WHERE table_schema IN ('nagios', 'nagiosql', 'nagiosxi');" | mysql -h 127.0.0.1 -uroot -pnagiosxi --table

Please send me a copy of your profile, you can download it from Admin > System Profile > Download Profile.

Run this command (as root) and leave it running:

Code: Select all

tail -Fn0 /var/log/httpd/error_log /var/log/httpd/ssl_error_log
Then replicate the 500 error again and send the full output of the still running tail command above.
dbcummings
Posts: 130
Joined: Thu Dec 13, 2018 8:37 am

Re: API 500 Internal Server Error

Post by dbcummings »

PM sent with requested data.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: API 500 Internal Server Error

Post by ssax »

Are all XI systems the same version?

I see you have a crashed table (not our table though):

Code: Select all

| nagios_XXXXXXXXXXXX_view | NULL |
Please repair it (I would also recommend you not add custom tables to our databases, we don't account for them in our scripts, create a different database for custom stuff):

Code: Select all

https://support.nagios.com/kb/article.php?id=24
I'm not seeing anything in your logs showing issues.

Please send me your /etc/php.ini from a non-working one.
dbcummings
Posts: 130
Joined: Thu Dec 13, 2018 8:37 am

Re: API 500 Internal Server Error

Post by dbcummings »

php.ini submitted via pm.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: API 500 Internal Server Error

Post by ssax »

Please edit your /etc/php.ini and change these:

Code: Select all

max_execution_time = 60
max_input_time = 120
max_input_vars = 5000
memory_limit = 256M
To these:

Code: Select all

max_execution_time = 300
max_input_time = 300
max_input_vars = 100000
memory_limit = 1024M
Then restart apache on it and test the API call again:

Code: Select all

service httpd restart
Let us know the results.
Locked