[Nagiosplug-devel] check_mysql should support a command line option for a MySQL defaults file

Wolfram Schlich lists at wolfram.schlich.org
Sat Jan 27 14:20:48 CET 2007


* Wolfram Schlich <lists at wolfram.schlich.org> [2006-11-24 00:38]:
> Hi!
> 
> IMHO check_mysql currently lacks a command line option to specify an
> alternate MySQL defaults file (aka ~/.my.cnf).
> The 'mysql' command line program for example supports --defaults-file.
> 
> 'check_mysql --help' itself warns about using '--password' in order
> to supply a password for MySQL authentication.
> 
> Thus, the only secure and sane way to supply a password,
> and even more important, *different* passwords for checking *multiple*
> databases or MySQL servers, is via multiple specific MySQL
> defaults files.

I believe found an ugly workaround :)

Here is my original proposal on how the issue could be solved by
extending check_mysql with an '-f' command line option to enable
it to read a specific my.cnf:

> 	define command{
> 		command_name check_mysql
> 		command_line $USER1$/check_mysql -H $HOSTADDRESS$ -P $ARG1$ -u $ARG2$ -d $ARG3$ -f $ARG4$
> 		}
> 
> 	define service{
> 		[...]
> 		host_name db1.example.com
> 		[...]
> 		check_command check_mysql!3306!nagios!mysql!/var/nagios/mysql.db1.example.com.cnf
> 		}
> 
> 	define service{
> 		[...]
> 		host_name db2.example.com
> 		[...]
> 		check_command check_mysql!3306!nagios!mysql!/var/nagios/mysql.db2.example.com.cnf
> 		}

Here is my workaround requiring no modification to check_mysql:

> 	define command{
> 		command_name check_mysql
> 		command_line /usr/bin/env HOME=$ARG4$ $USER1$/check_mysql -H $HOSTADDRESS$ -P $ARG1$ -u $ARG2$ -d $ARG3$
> 		}

The idea is to supply an alternative HOME environment variable to
check_mysql. The mysql client library then looks for my.cnf in that directory.
I verified this using "strace -e stat64 /usr/nagios/libexec/check_mysql".

Here are the services:

> 	define service{
> 		[...]
> 		host_name db1.example.com
> 		[...]
> 		check_command check_mysql!3306!nagios!mysql!/var/nagios/my.cnf.d/db1.example.com
> 		}
> 
> 	define service{
> 		[...]
> 		host_name db2.example.com
> 		[...]
> 		check_command check_mysql!3306!nagios!mysql!/var/nagios/my.cnf.d/db2.example.com
> 		}

check_mysql should then, regarding the above two examples, read the
files /var/nagios/my.cnf.d/db1.example.com/my.cnf resp.
/var/nagios/my.cnf.d/db2.example.com/my.cnf.

While this should do it's job, it would be much nicer to have a
patched check_mysql command.
Is still nobody willing to do it? :)

Comments, please.
-- 
Regards,
Wolfram Schlich <wschlich at gentoo.org>
Gentoo Linux * http://dev.gentoo.org/~wschlich/




More information about the Devel mailing list