How to use check_mysql plugin?

hi all,
i 'm still new in nagios ,
i have some servers which mysql service is running on them ,
i want to check this service on them ,
i have seen the check_mysql plugin in libexec subdirectory of nagios,
but i don’t know how to use it from command line ,
ofcourse i want to define it in checkcommand.cfg file too,
would you help me ?
tnx alot.

:smiley:

chec the NRPE and NCSA plugins.
You’ll need to run the check on the remote machine and get the result back…

or if you need very little info you could make a check_tcp on port 3306. but in case of an error you wouldn’t know what’s going wrong.

Luca

oh i think NRPE and NCSA are for remotely checking local check command,isn’t it ?
but check_mysql could be checked on network without NRPE or NCSA .yeah?
anyway i used it and will write it here with hope to be usefull for other newbies like myself.

hm, I don’t see any problem here, but the command.cfg define is simple as that:

define command{
command_name check_mysql
command_line $USER1$/check_mysql -H $HOSTADDRESS$ -P $ARG1$ - u $ARG2$ -p $ARG3$
}
and in service.cfg:

icheck_command check_mysq!3306!mysql_user!mysql_passwd

But for ourself, as we have a lot of mysql servers to check, we did following:
we created a “scriptwrapper” that reads
config file where is defined all params for check_mysql script:
host;port;user;passwd;additional params

define the command like:
define command{
command_name script_wrapper
command_line $USER1$/script_wrapper $ARG1$
}

and in the service.cfg:

check_command script_wrapper!<config_file>

then we don’t need to change ther Nagios config files and restart Nagios.

i think the grant on a mysql database should be given to the username that nagios use to check mysql service,
i did it , what about you?

and i used $USER3,$USER4 instead of $ARG2,$ARG3.

hm, I don’t really understand what do you mean.
if you can get the access to the mysql database from the Nagios server with help of “mysql” client, you can use the same username for nagios pluging.

I didn’t specify USER3,$USER4 for my config, because I use the config file where all necessary data are configured, and you can pass the user/password from the service config file, for this you should use $ARG1$ etc.

$USER3$ and $USER4$ and so-on are defined in the resource.cfg file and are hidden from the services.cfg file. That can be important when you want to hide login information from the eyes of those that have access to view the config files from the website cgi pages.