Problem when I start Nagios with Mysql


#1

Hi,

I’m a beginner with Nagios.

I follow different manual to install Nagios on Debian.

I’ve create a Mysql database + Nagios User + config etc/nagios/resource.cfg and /etc/nagios/cgi.cfg to put the database name + User and password.

I’ve put the check_nagios_db in /etc/nagios/

When I launch **./usr/sbin/nagios -v /etc/nagios/nagios.cfg **
I have this message :

*(Things look okay - No serious problems were detected during the pre-flight check) *

But …

When I do this

/etc/init.d/nagios start

I have this error message :

*Starting nagios: DBI connect(‘database=;host=;port=’,’’,…) failed: Access denied for user ‘root’@‘localhost’ (using password: NO) at /etc/nagios/check_nagios_db line 55
nagios. *

And I can see this in snort log :

[1121899930] Error: Could not connect to MySQL database ‘’ on host ‘’ using username ‘’ and password ‘XXXXXX’. Retention data will not be processed or save$
[1121899930] Error: Could not connect to MySQL database ‘’ on host ‘’ using username ‘’ and password ‘XXXXXX’ for comment data!
[1121899930] Error: Could not connect to MySQL database ‘’ on host ‘’ using username ‘’ and password ‘XXXXXX’ for downtime data!

The Web interface work but I can’t do nothing, and i have this message:

*Whoops!
Error: Could not read host and service status information!

The most common cause of this error message (especially for new users), is the fact that Nagios is not actually running. If Nagios is indeed not running, this is a normal error message. It simply indicates that the CGIs could not obtain the current status of hosts and services that are being monitored. If you’ve just installed things, make sure you read the documentation on starting Nagios.

Some other things you should check in order to resolve this error include:

Check the Nagios log file for messages relating to startup or status data errors.
Always verify configuration options using the -v command-line option before starting or restarting Nagios!
Make sure you’ve compiled the main program and the CGIs to use the same status data storage options (i.e. text file or database). If the main program is storing status data in a text file and the CGIs are trying to read status data from a database, you’ll have problems.

Make sure you read the documentation on installing, configuring and running Nagios thoroughly before continuing. If all else fails, try sending a message to one of the mailing lists. More information can be found at nagios.org. *

I’ve tried to reinstall but I have the same probleme… and I cant found the solution in any forum or documentation…

Somebody can help me please ?

Thx in advance…


#2

You also have to create a user with certain permissions in mysql (I just used root). Make sure you create this user, give it a password, and set the xXddb_database=, xXddb_username= and xXddb_database= to the right values in cgi.cfg(where X is e,s, etc, there are a couple entries for different types of config data in the database). The default mysql host is localhost, so this should be ok if the mysql server is running on the same computer as the nagios server. Also, make sure you run the create_mysql.gz script in /usr/share/doc/nagios-mysql (i’m assuming you are running debian). Hope this helps.


#3

Hi moore thx for your help :),

Yes I run nagios on Debian.

I already run create_mysql.gz script …

You can see below what I made for the mysql database.

For the username and database name i’ve put in

etc/nagios/resource.cfg and **/etc/nagios/cgi.cfg **

xsddb_database=nagios
xsddb_username=nagios
xsddb_password=le mot de passe du user nagios

(but I don’t understand what i must do with the x in front sddb )

I do this for the mysql data base :

mysqladmin -u root -p create nagios

zcat /usr/share/doc/nagios-mysql/create_mysql.gz | mysql -u root -p nagios

mysql -u root -p nagios

mysql> GRANT LOCK TABLES ON nagios.* TO [email protected] IDENTIFIED BY ‘password’;
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON nagios.* TO [email protected];

And in the nagios.cfg I’ve this :

nagios_user=nagios
nagios_group=nagios

So, I don’t understand why nagios try to start the database with [email protected]:frowning:

Have you one another idea ?

Thanks a lot for your help …


#4

nagios is not triing to start the database, it’s triing to connect to the nagios database using root with no password when it attempts to find out the status of nagios (up or down). The script doing this is as it says, “/etc/nagios/check_nagios_db” The line where you might see the trouble is line 55.
vi +55 /etc/nagios/check_nagios_db
There are other plugins that will check_nagios in the plugins src, you may want to try a different one, if you can’t fix that one.


#5

Is your nagios user in the nagios group, or in the users group? I can’t remember what debian does by default when you useradd. Also, have you tried to connect to the database with phpmyadmin or webmin? In debian, just do apt-get install phpmyadmin , the connect to the phpmyadmin user interface and see if the database shows up. If it won’t connect, either the server isn’t running or the username and password for nagios isn’t set correctly in mysql. Beyond that, I don’t know. It seems like you have done everything you are supposed to. I will check my debian install and see if I can find anything you missed.


#6

the X in my previous post just meant that you had to add the username/password and database name for a couple different sections in cgi.cfg that just differed by the one letter. i.e.:
xsddb_database=somedatabase
xsddb_username=root
xsddb_password=whateveryouwant

and

xcddb_database=somedatabase
xcddb_username=root
xcddb_password=whateveryouwant

etc…


#7

When I log the nagios user with phpmyadmin in the nagios database, there is no problem, I can see the nagios database :

nagios (12)
hostcomments
hostdowntime
hostextinfo
hostretention
hoststatus
programretention
programstatus
servicecomments
servicedowntime
serviceextinfo
serviceretention
servicestatus

In the 55 line of **check_nagios_db **I have this :

my $dbh = DBI->connect($dsn, $dbuser, $dbpass, {‘RaiseError’ => 1});

For the nagios user under debian, I can see in the /etc/group :

nagios:x:109:

there is something else to see in which group is nagios ?

I will check for another one **check_nagios **(have you one idea for special check_nagios ?)

Thanks a lot.


#8

Just for your information i use the Nagios Version 1.3
October 24, 2004…


#9

I have in my
src/nagios-plugins-1.4/plugins/check_nagios
src/nagios-plugins-1.4/contrib/check_nagios_db.pl
I use the latter.

wiki.tryphon.org/How_to_install_ … _nagios_db
Take a look, it might help you out.


#10

I want try this one **src/nagios-plugins-1.4/contrib/check_nagios_db.pl **

but I don’t know where i put the database name and the username/password …

Or this file take the cgi.cfg config ?

xeddb_database=nagios
xeddb_username=nagios
xeddb_password=password nagios user

Thanks


#11

check_nagios_db.pl uses the login information that you have provided in the cgi.cfg file for …
xsddb_host=whatever
xsddb_port=3306
xsddb_database=nagios
xsddb_username=whatever
xsddb_password=whatever