Linux MySQL server monitoring

last updated in Categories News

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.

Setup password, this the ONLY one you need to setup.

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.

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, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.