Page 1 of 3

DB Connect Error [nagiosxi]: Database connection failed

Posted: Sun Mar 06, 2011 6:27 am
by TSCAdmin
Hello,

We are running Nagios XI 2009R1.3 and trying to build a development environment.

I did a fresh Nagios 2009R1.4B install on the new machine and followed the instructions at http://assets.nagios.com/downloads/nagi ... kuprestore to have an identical configuration environment.

I was able to install Nagios XI and everything seems to be running fine except NagiosQL's connection to the DB. I tried looking up

http://support.nagios.com/wiki/index.ph ... _failed.22

but it doesn't help.

Is there something I am missing?

Thanks

Re: DB Connect Error [nagiosxi]: Database connection failed

Posted: Mon Mar 07, 2011 12:02 pm
by mguthrie
Actually if you're receiving the above error, that's a postgresql problem. Try restarting your postgresql service and see if that does the trick.

Re: DB Connect Error [nagiosxi]: Database connection failed

Posted: Mon Mar 07, 2011 1:12 pm
by TSCAdmin
thank you for the response, mguthrie!

i did restart postgresql after reading the FAQ but it did not solve the problem. as a matter of fact i restarted all the services but i am getting the same error.

i tried to connect to psql and got the following:

psql: FATAL: database "root" does not exist

please pardon my postgresql ignorance but is there anyway i could fix this?

p.s. i wonder what is the need of two databases when mysql could do all this work for nagios.

thanks.

UPDATE: i get psql: FATAL: database "root" does not exist on the production nagios server as well so i doubt it will be a problem

Re: DB Connect Error [nagiosxi]: Database connection failed

Posted: Tue Mar 08, 2011 10:28 am
by mguthrie
What is the output from:

Code: Select all

service postgresql status

To log in to postgres, you could use the following command:

Code: Select all

psql -U nagiosxi -d nagiosxi
although you shouldn't have any reason to do so, the above command let you know if it's running.

i wonder what is the need of two databases when mysql could do all this work for nagios.
nodutils as well as the Core Config Manager utilize mysql, while the XI interface uses postgresql for user and session information.


Do you have any special configurations on your system like SSL or are you running your server behind a proxy?

Re: DB Connect Error [nagiosxi]: Database connection failed

Posted: Wed Mar 09, 2011 6:12 am
by TSCAdmin
Thank you for your response mguthrie. Below is the output:

Code: Select all

# service postgresql status
postmaster (pid 2750 2749 2748 2746 2744) is running...

# ps -ef | grep postgres
postgres  2744     1  0 Mar07 ?        00:00:00 /usr/bin/postmaster -p 5432 -D /var/lib/pgsql/data
postgres  2746  2744  0 Mar07 ?        00:00:00 postgres: logger process
postgres  2748  2744  0 Mar07 ?        00:00:00 postgres: writer process
postgres  2749  2744  0 Mar07 ?        00:00:00 postgres: stats buffer process
postgres  2750  2749  0 Mar07 ?        00:00:00 postgres: stats collector process
root     31269 31070  0 01:05 pts/0    00:00:00 grep postgres
There are no special configurations on the server, no SSL/Proxy etc. There is nothing in error_log as well. What else could be the reasons?

Thanks

Re: DB Connect Error [nagiosxi]: Database connection failed

Posted: Wed Mar 09, 2011 11:42 am
by mguthrie
Hmm, I'm a little bit unsure as to what would be causing this. I'm going to have to try a few things and we'll see if any of these hit home.

Check for broken postgres sequences by running the following script.
/usr/local/nagiosxi/tools/fix_postgres_sequences.sh

Reset your backend credentials from the Admin->Reset Security Credentials page.

I always hate suggesting this, but try restarting the server itself if the above suggestions don't fix it.

If none of those work, we'll look at doing a remote session.

Re: DB Connect Error [nagiosxi]: Database connection failed

Posted: Wed Mar 09, 2011 12:36 pm
by TSCAdmin
Running sequences script yielded the following result

Code: Select all

Nagios XI Postgres Database Sequence Information

OLD VALUES
--------------
xi_commands_command_id_seq = 1517
xi_events_event_id_seq = 1527483
xi_meta_meta_id_seq = 1527544
xi_options_option_id_seq = 53
xi_sysstat_sysstat_id_seq = 29
xi_usermeta_usermeta_id_seq = 666
xi_users_user_id_seq = 39

NEW VALUES
--------------
xi_commands_command_id_seq = 1517
xi_events_event_id_seq = 1527483
xi_meta_meta_id_seq = 1527544
xi_options_option_id_seq = 99
xi_sysstat_sysstat_id_seq = 99
xi_usermeta_usermeta_id_seq = 666
xi_users_user_id_seq = 49

Admin page would not open for me since NagiosQL is not connecting. I also tried restarting the server, it did not solve the problem :)

It seems NagiosQL PHP scripts are failing somewhere while connecting to postgresql. What do you suggest next?

Cheers

Re: DB Connect Error [nagiosxi]: Database connection failed

Posted: Wed Mar 09, 2011 3:40 pm
by rdedon
http://[server or IP Address]/nagiosxi/admin/credentials.php
could you try linking directly to see if it can be reset please?

Re: DB Connect Error [nagiosxi]: Database connection failed

Posted: Wed Mar 09, 2011 7:53 pm
by TSCAdmin
Hello rdedon, unfortunately the same error is being displayed while trying to open the url you suggested

Code: Select all

DB Connect Error [nagiosxi]: Database connection failed 

Re: DB Connect Error [nagiosxi]: Database connection failed

Posted: Thu Mar 10, 2011 4:54 am
by Box293
I recently saw this occur when the hard disk of the Nagios XI VM was full.

Execute this from the command line, this will show you the disk usage.

df -h

To add more space follow the Disk Resize Procedure