# Nagios and Mysql

## paleck

I am currently trying to get nagios running on my server.  I compiled with the mysql USE tag on and verified that nagios seemed to have compiled mysql support.  Unfortunately, although the system itself will run I can't use the web interface.  In the logs it shows this message:

 *Quote:*   

> Jul 30 15:35:16 [nagios] Error: Could not insert retention data for host 'bb1' in table 'hostretention'

 

The notifications seem to be running and monitoring everything, but the web interface and db logging are useless:

 *Quote:*   

> 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. 
> ...

 

Please let me know if you have any ideas

Also, this server is running Apache 2 and Nagios seems to not be able to read what user is logging in.  As long as they authenticate with the htpasswd, then it things they are logged in as the default user, not their user.  I don't know if this is related to the mysql problem or if Nagios doesn't play well with Apache 2 yet.

----------

## quikchaos

I am not sure if I can help you figure out your issue, but I will tell you that I am running the latest Nagios (Template-based) and the latest Apache 2  on my Gentoo server and it is running very smoothly. 

I once tried the MySQL approach w/ Nagios with no avail. I found this article from a Nagios Dev a while back and it seems MySQL support for Nagios may become a thing of the past. I would stick with the Template-based method, but that's just my opinion.

 *Quote:*   

> FROM: Ethan Galstad
> 
> DATE: 02/20/2002 16:03:54
> 
> SUBJECT: RE:  [Nagios-users] --with-mysql-objects does it work? 
> ...

 

----------

## dfannin

the default emerge for nagios on gentoo 1.4 iif you have the "mysql" use flag set it to build nagios with to use mysql for the various status and confguration databases.  This is not what most users of nagios intend, and it appears to be unintended side effect of using the gentoo use flags.  Most users of nagios don't use the mysql or pgsql options, due the reasons quickchaos has listed, and it appears the the mysql option is a beta feature for nagios anyway.

The fastest way to resolve this is to do a :

USE="-mysql" emerge nagios-core

which will rebuild it without mysql options.  You will have to manual monitor later emerges to make sure that a new version of nagios will not override this option later however.  One more reason to love the gentoo ebuild system.

----------

## Urgo

Oh thank you.  I actually thought I tried that a week ago but it didn't work. Anyway I had the same probelm:

[1080094055] Error: Could not lock status data tables in database ''

[1080094070] Error: Could not lock status data tables in database ''

[1080094085] Error: Could not lock status data tables in database ''

[1080094695] Error: Could not insert retention data for host 'linux1' in table 'hostretention'

etc

So I ran

# USE="-mysql -postgres" emerge nagios-core 

edited all the database stuff out of the config files

and then restarted nagios and everything worked!

Thanks =]

----------

## mathew

 *Urgo wrote:*   

> 
> 
> So I ran
> 
> # USE="-mysql -postgres" emerge nagios-core 
> ...

 

This fixed the following compilation error I was facing when attempting to emerge nagios-core.

```
../xdata/xrddb.c:270: error: `CONNECTION_BAD' undeclared (first use in this function)

../xdata/xrddb.c:335: error: `PGRES_FATAL_ERROR' undeclared (first use in this function)

../xdata/xrddb.c:335: error: `PGRES_BAD_RESPONSE' undeclared (first use in this function)

```

Suspect the compilation error has something to do with postgres not being installed properly.

----------

## suso

Don't want to be a wet blanket, but I think its generally a bad idea for any monitoring program to depend on any service other than the machine itself.   What happens if mysql or postgresql has problems?

I was surprised to find that my nagios had used my mysql and postgresql USE flags, which was causing me problems.

----------

## flickerfly

I wonder if anyone has managed to get MYSQL support to work. If not, should be report a bug, recommending the removal based on the dev article above of the mysql support in the ebuild?

If no one says no and I don't forget I'll make a bug report soon.

----------

