DB Connect Error [nagiosxi]: Database connection failed

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
TSCAdmin
Posts: 155
Joined: Wed Apr 14, 2010 3:00 pm
Location: India

DB Connect Error [nagiosxi]: Database connection failed

Post 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
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

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

Post 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.
TSCAdmin
Posts: 155
Joined: Wed Apr 14, 2010 3:00 pm
Location: India

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

Post 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
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

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

Post 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?
TSCAdmin
Posts: 155
Joined: Wed Apr 14, 2010 3:00 pm
Location: India

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

Post 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
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

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

Post 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.
TSCAdmin
Posts: 155
Joined: Wed Apr 14, 2010 3:00 pm
Location: India

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

Post 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
rdedon
Posts: 578
Joined: Sat Nov 20, 2010 4:51 pm

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

Post by rdedon »

http://[server or IP Address]/nagiosxi/admin/credentials.php
could you try linking directly to see if it can be reset please?
Rene deDon
Technical Team
___
Nagios Enterprises, LLC
Web: http://www.nagios.com
TSCAdmin
Posts: 155
Joined: Wed Apr 14, 2010 3:00 pm
Location: India

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

Post 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 
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

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

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked