Some time due to the high load MySQL or MariaDB server gets killed by Linux and Unix operating system. So we need to make sure that whenever it gets killed restart the MySQL server and send an email notification along with the status of MySQL servers. This is simple and yet effective script till sysadmins comes online and fix the issue.
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):
Change this if your mysql admin user is not root user.
Set up 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. For systemd based system use systemctl start mysql command.
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 or every five minutes on Linux or Unix server:
* * * * * /path/to/monitor_mysql.bash
A note about mytop
One can use the mytop app. It display MySQL/MariaDB server performance information like top format. It is a console-based tool for monitoring the threads and overall performance of MySQL and MariaDB servers. The user interface is modeled after familiar Unix top application.
How to install mytop on an Ubuntu/Debian
Install mytop on a Fedora Linux
Execute the following dnf command:
sudo dnf install mytop
Install mytop on a CentOS/RHEL/Oracle Linux
Linux MySQL and MariaDB server monitoring with mytop
Simply run the following
See mytop project home page here for more information.