Page 1 of 1

Database connection failed SQL

Posted: Wed Apr 27, 2016 11:18 am
by james_lin
Hi Guys,

We have nagios running for several years. Right now, I got "Database connection failed SQL" error message. I also tried to run "/usr/local/nagiosxi/scripts/repair_databases.sh"; however, it didn't fix the problem.
Please help.

OS: CentOS release 5.6 x64
Nagios XI is manual installed.


Thanks,
James

Re: Database connection failed SQL

Posted: Wed Apr 27, 2016 11:20 am
by rkennedy
What version of XI are you running? Can you PM over a profile for us to look at? (Admin -> System Profile -> Download Profile)

Re: Database connection failed SQL

Posted: Wed Apr 27, 2016 11:40 am
by james_lin
Hi,

My Nagios Core is 4.1.1
Does it help?

Since my Nagios is down right now, I can't download profile. Could you show me the other way to get profile from command line?

Thanks.

Re: Database connection failed SQL

Posted: Wed Apr 27, 2016 2:32 pm
by tgriep
Can you login to the XI server as root, run the following command and post the output?

Code: Select all

ps -ef
Also, can you post a screen shot of the Web Interface error as well?
Thanks

Re: Database connection failed SQL

Posted: Wed Apr 27, 2016 2:52 pm
by james_lin
Hi,

I attached ps -ef output and screenshot of error message.
Please check it.

Thanks,
James

Re: Database connection failed SQL

Posted: Wed Apr 27, 2016 3:53 pm
by ssax
First, check the free space:

Code: Select all

df -h
df -i
Then, make sure the DB services are okay.

Check /var/log/mysqld.log and see if you see any crashed tables messages (happening now).

If there are no crashed tables or any other error messages, let's restart the stack:

Code: Select all

service nagios stop
service ndo2db stop
service mysqld restart
service postgresql restart
service httpd restart
service ndo2db start
service nagios start
Did you make any changes? Harden the system, OS updates, XI upgrades, DB password changes, anything? Did it just start happening or did a change cause it?

Re: Database connection failed SQL

Posted: Wed Apr 27, 2016 4:53 pm
by Box293
Following this KB article should resolve that problem:

https://support.nagios.com/kb/article.php?id=25

Specifically the postgres vacuum.

Re: Database connection failed SQL

Posted: Thu Apr 28, 2016 11:18 am
by james_lin
Great!! The problem is on postgres. After I run the code below, my nagios is up and running now.

Code: Select all

service postgresql stop
su postgres
echo "VACUUM FULL;" > /tmp/fix.sql
postgres -D /var/lib/pgsql/data nagiosxi < /tmp/fix.sql
postgres -D /var/lib/pgsql/data postgres < /tmp/fix.sql
postgres -D /var/lib/pgsql/data template1 < /tmp/fix.sql
exit
service postgresql start
Thanks a lot for your support.

Re: Database connection failed SQL

Posted: Thu Apr 28, 2016 1:57 pm
by rkennedy
Great to hear! Going to mark this one as resolved, and close it up!

Feel free to create a new thread if you need any assistance in the future.