check_mysql_health - couldn't get information

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
vojd.guja
Posts: 1
Joined: Tue Aug 18, 2015 6:24 am

check_mysql_health - couldn't get information

Post by vojd.guja »

Hello everyone.

Today I'm trying to manage to configure nagios plugin so that, it'll be able to monitor MySQL server, but unfortunately I didn't success. :(

I've installed Nagios Core v.4.0.8 on CentOS Server x64 v.6.6. I have already configured a lot of different services on other servers and also on this particular server as well, but I've got stucked on MySQL. The Server is also CentOS based, it runs Asterisk server on FreePBX v.12.0.74, so as it uses MySQL for storing data, I want to monitor its health. I've installed plugin check_mysql_health on my nagios server, opened connection, granted access and than tested by running the following command from Nagios server:

Code: Select all

/usr/local/nagios/libexec/check_mysql_health --hostname xxx.xxx.xxx.xxx --username username --password 'password' --database asterisk --mode 'threads-connected'
and it returns:

Code: Select all

OK - 2 client connection threads | threads_connected=2;10;20
So as I understand, it's working, but the problem begins, when i try to configure it through the service definitions.

First I added the following record into commands.cfg:

Code: Select all

# 'check_mysql_health' command definition
define command{
        command_name       check_mysql_health
        command_line       $USER1$/check_mysql_health --hostname $HOSTADDRESS$ --username $ARG1$ --password $ARG2$ --database $ARG3 --mode $ARG4$
        }
Then I've added the following service definition into host's configuration file (which as I said already contains other service definitions and the work perfectly):

Code: Select all

# Asterisk MySQL Database monitoring
define service {
                use                        generic-service
                host_name                  asterisk
                service_description        Asterisk MySQL Database
                check_command              check_mysql_health!username!'password'!asterisk!threads-connected
                contact_groups             admins
}
Well, after reloading nagios server, on web interface I'm getting green status - OK and instatus information field, there's a message: "Please select a mode" :shock:

I have already tried different kind of modes, but all the same. the only thing I'm in doubt is that my current password for MySQL user is very strong and contains special characters (! letter as well), that why I tried to escape it with quotes, maybe that is the problem? But in that case, why I'm getting green status :? I don't know, please help, as I've lost entire working day on this issue.

Thanks in advance.
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: check_mysql_health - couldn't get information

Post by hsmith »

vojd.guja wrote:Hello everyone.

Today I'm trying to manage to configure nagios plugin so that, it'll be able to monitor MySQL server, but unfortunately I didn't success. :(

I've installed Nagios Core v.4.0.8 on CentOS Server x64 v.6.6. I have already configured a lot of different services on other servers and also on this particular server as well, but I've got stucked on MySQL. The Server is also CentOS based, it runs Asterisk server on FreePBX v.12.0.74, so as it uses MySQL for storing data, I want to monitor its health. I've installed plugin check_mysql_health on my nagios server, opened connection, granted access and than tested by running the following command from Nagios server:

Code: Select all

/usr/local/nagios/libexec/check_mysql_health --hostname xxx.xxx.xxx.xxx --username username --password 'password' --database asterisk --mode 'threads-connected'
and it returns:

Code: Select all

OK - 2 client connection threads | threads_connected=2;10;20
So as I understand, it's working, but the problem begins, when i try to configure it through the service definitions.

First I added the following record into commands.cfg:

Code: Select all

# 'check_mysql_health' command definition
define command{
        command_name       check_mysql_health
        command_line       $USER1$/check_mysql_health --hostname $HOSTADDRESS$ --username $ARG1$ --password $ARG2$ --database $ARG3 --mode $ARG4$
        }
Then I've added the following service definition into host's configuration file (which as I said already contains other service definitions and the work perfectly):

Code: Select all

# Asterisk MySQL Database monitoring
define service {
                use                        generic-service
                host_name                  asterisk
                service_description        Asterisk MySQL Database
                check_command              check_mysql_health!username!'password'!asterisk!threads-connected
                contact_groups             admins
}
Well, after reloading nagios server, on web interface I'm getting green status - OK and instatus information field, there's a message: "Please select a mode" :shock:

I have already tried different kind of modes, but all the same. the only thing I'm in doubt is that my current password for MySQL user is very strong and contains special characters (! letter as well), that why I tried to escape it with quotes, maybe that is the problem? But in that case, why I'm getting green status :? I don't know, please help, as I've lost entire working day on this issue.

Thanks in advance.
Hi vojd.guja,

The ! in the password is absolutely going to cause some problems. Having that in the password messes with the structure of the command. The easy answer is changing the password to something without ! in it. Having the quotes around this isn't going to make it work better, unfortunately.

If changing that password is not an option, here is a quote from another thread on how to fix this.
abrist wrote:Use the nagios resource.cfg file to add the password as a user macro as that file is provided for the cases that invlove strings with illegal macro characters in them. Simply open:

Code: Select all

/usr/local/nagios/etc/resource.cfg
And add a new $USERn$ macro, then call that directly in the service definition by replacing the password with the user macro specified in the resource.cfg file.
Former Nagios Employee.
me.
Locked