MySql monitoring using nagios

About :-

Mysql Check is a very good plugin for nagios . We can use this to monitor mysql health status like mysql connection time , threads connected etc.

Installation :-


tar -zxf check_mysql_health-2.1.5.tar.gz

cd check_mysql_health-2.1.5


make & make install


In Mysql Server

mysql> GRANT usage ON *.* TO ‘nagios’@’nagios-server-ip’ IDENTIFIED BY ‘pass’;

Check the connection from nagios server

$ ./check_mysql_health –hostname mysql-server  –username nagios –password pass  –mode connection-time

Can’t locate Time/ in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at ./check_mysql_health line 940.

BEGIN failed–compilation aborted at ./check_mysql_health line 940.

I got the above error while trying to check this plugin locally and I have fixed this using the following

$  perl -MCPAN -e shell

Can’t locate in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .).

BEGIN failed–compilation aborted.

( cpan is not present in the server , so I have installed cpan first and installed all the other modules using cpan )

$ yum install perl-CPAN

$ perl -MCPAN -e shell

$ cpan[1]> install Time::HiRes

./check_mysql_health –hostname mysql-server  –username nagios –password pass  –mode connection-time

OK – 0.46 seconds to connect as nagios | connection_time=0.4560s;1;5

( This time its worked 🙂 )

./check_mysql_health –hostname mysql-server  –username nagios –password pass  –mode threads-connected

CRITICAL – 34 client connection threads | threads_connected=34;10;20

Nagios configuration

# service ‘MySQL connection-time’

define service{

use                                   generic-service

host_name                     MYSQL-Server

service_description     MySQL connection-time

check_command          check_mysql_health!nagios!pass!connection-time!2!4

contact_groups            admins


# service ‘MySQL threads-connected’

define service{

use                                 generic-service

host_name                   MYSQL-Server

service_description    MySQL threads-connected

check_command   check_mysql_health!nagios!pass!threads-connected!80!100

contact_groups          admins


( after editing the corresponding hosts cfg file verify the nagios configuration and restart the nagios serve r)

$ nagios -v /etc/nagios/nagios.cfg

$ /etc/init.d/nagios restart

Hey you did that ..Its a fantastic nagios plugin  to monitor mysql health for high traffic DB server ‘s 😉

  • gary

    Exactly fixed my problem. I owe you a beer! Thanks. Centos 6.5 / Nagios 4.0.6

  • Skyrim

    yo very nice solved my problem now the plug in is working. keep on sharing mate

  • lkajdhflkjshfls

    what a stupid page, which displays apostrophes wrong !! Copy paste is not possible!!!!

  • Hi Skyrim : Seems that the issue with the theme . I will try to fix it ! 🙂 . Thanks for the comment and reading my blog .

  • Hi Gary , Thanks for the beer !! 🙂