Linux MySQL and MariaDB server monitoring

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):

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

Set up 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. 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

Run the apt-get command or apt command:
sudo apt install mytop

Install mytop on a Fedora Linux

Execute the following dnf command:
sudo dnf install mytop

Install mytop on a CentOS/RHEL/Oracle Linux

Turn on EPEL repo for mytop and run the following yum command:
sudo yum install mytop

Linux MySQL and MariaDB server monitoring with mytop

Simply run the following
Linux MySQL and MariaDB server monitoring
See mytop project home page here for more information.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

Comments on this entry are closed.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum