Linux MySQL server monitoring

Posted on in Categories News last updated August 17, 2005

Some time due to high load MySQL server gets killed by OS. So we need to make sure that whenever it gets killed restart the mysql server and send an email notification along with status of mysql server. This is simple and yet effective script.

Please see the monitor_mysql.bash script (download link at the end of script)

Customizing the script. Open the script in text editor such as vi, you can customize following 5 directives (read as variable):

1) MUSER=”root”
Change this if your mysql admin user is not root.

2) MPASS=”SET-ROOT-PASSWORD”
Setup password, this the ONLY one you need to setup.

3)MHOST=”localhost”
Setup hostname if it is not localhost

4) MSTART=”/etc/init.d/mysql start”
This is default on Debain Linux, you need to setup this according to your UNIX/Linux/BSD OS.

5) EMAILID=”[email protected]
Set Email ID to send notification.

Once all done save the file and install script as cron job. For example run this script every minute
* * * * * /path/to/monitor_mysql.bash

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.