Mytop – Tool for Monitoring MySQL/MariaDB Performance in Linux
Last Updated :
09 Dec, 2022
Mytop is a completely free and open-source tool that is used for monitoring MySQL and MariaDB databases. It was written in Perl by Jeremy Zawodny. It is almost similar to its counterpart top which is also used for monitoring purposes.
Mytop provides the user with a shell through which the user can monitor different activities of the MySQL/MariaDB database. The shell gives information about the threads, queries per second, the performance of the database, etc. Mytop is included in Fedora and Debian distros by default, so the user just has to install it. For RHEL the user must enable the EPEL repository.
The Linux distribution that we are using in this article will be Centos, you can use any distro of your choice. Make sure you have an active service of the Mysql database.
Getting started with Mytop
Step 1: Installing Mytop on the system
Use the below command to install mytop on your system.
sudo yum install mytop
Step 2. Confirm the installation
To see if Mytop is installed or not use the -whereis command, if you get a location then Mytop is installed successfully.
whereis mytop
Step 3. Using Mytop to monitor databases
Let us see how to monitor a database using Mytop. For the purpose of this article, we will create a sample database named mukul.
Note: If a database is not specified then Mytop will use a “test” database.
mytop --prompt -d mukul
After you write the above command, you will be asked to provide the root password for MySQL. Enter it and you will see the Mytop monitoring shell.
Step 4. Changing the config file
Writing the entire command while running Mytop every time can be very tedious. For saving time we can edit the Mytop config file, and add our username and database there. Add the below lines of code to the config file.
nano ~/.mytop (text editor is nano)
user=root
pass=<custom_password>
host=localhost
db=<your_database>
delay=4
port=3306
socket=
Now we can use Mytop directly without writing any additional commands:
mytop
Note: The Mytop shell can also be opened by mentioning the specific admin and database name, but that is not recommended as during this command the password can be stored in the shell’s command history file which can be used by an unauthorized person.
mytop -u root -p <password> -d sample_db (Not recommended)
Step 5. Viewing and Interpreting the Mytop Display
Let us now see the meaning of the display that we get after using the below command.
mytop --prompt
The above view which is opened after writing the command is known as the thread view. The first 4 lines of the view are known as the header, which contains summarized information about the MYSQL server.
Linewise information about the headers:
- First line: This line shows the hostname and the version of the MYSQL server. Along with that, the server uptime can also be seen. The format of the uptime is: days + hours:minutes:seconds
- Second line: This line shows the total number of queries processed, the number of slow queries, average queries, and the percentage of Select, Insert, Delete and Update queries.
- Third line: All the real-time values are shown in this line since the last Mytop refresh. The first field shows the number of queries per second (qps). The second field is the number of slow queries per second. The last and final field in this line shows the percentage of queries since the last mytop refresh.
- Fourth line: This line shows the key buffer efficiency which is the number of times the keys are read from the buffer. Along with this it also shows the number of bytes that MYSQL has sent and received.
The second part:
The second part of the view shows the current MYSQL threads which are sorted on the basis of the time they have been idle ( in ascending order). The information shown is as follows:
- The id of the thread.
- Username and the host to which the user is connected.
- Database which is connected to the user.
- Idle time (in seconds).
- The command which is being executed by the thread.
- The first part of the query.
Note: If the command is in a sleep state then its corresponding query or state column will be blank.
More info about Mytop can be found on its man page.
man mytop
Conclusion:
So this was how can use Mytop on Linux to monitor the performance of your database. Tools like these can surely increase productivity. You can learn more about Mytop by exploring its features and by gaining practical experience with it.
Similar Reads
Simple Steps Migration From MySQL To MariaDB On Linux
MySQL and MariaDB are two different Relational Database Management Systems (RDBMS). Superficially, both of these software look and act in the same way. But there are many technical differences between them. So, before diving into the steps for migration, let's first understand what is MySQL and Mari
10 min read
Linux - Hegemon Modular System Monitoring Tool
Hegemon is a work-in-progress modular system monitor written in secure Rust programming language. This allows users to monitor utilization and hardware in a single dashboard. The system hardware and utilization information are collected through the use of variables like chan, termion, systemstat and
4 min read
Introduction to Firebase Performance Monitoring
Firebase Performance Monitoring is an important tool for developers and provides real-time measurements of an apps performance from the users perspective. In this article, We will learn about Firebase Performance Monitoring and its Importance along with How Firebase Performance Monitoring Works Intr
4 min read
Linux Sysstat Utilities For Monitoring System Performance
Sysstat is a useful utility that includes a number of programs for monitoring system resources, performance, and use. The sysstat package contains a number of programs that we all use on a daily basis. It also includes a program that can be used to collect all performance and activity data. Installi
1 min read
SAR command in Linux to monitor system performance
sar (System Activity Report) It can be used to monitor Linux system's resources like CPU usage, Memory utilization, I/O devices consumption, Network monitoring, Disk usage, process and thread allocation, battery performance, Plug and play devices, Processor performance, file system and more. Linux s
9 min read
How to Monitor Processor, Memory, Network Performance using dstat in Linux?
Do you want to run a quick performance test on your Linux machine? You may want to check the dstat command. Dstat is a versatile and efficient command that combines the features of several older tools such as vmstat, netstat, iostat, and ifstat to provide useful insights into Linux system performanc
2 min read
How to Change Default MySQL/MariaDB Port in Linux?
The default port that the MySQL database server runs under Linux is 3306/TCP. Use the commands below to change the default MySQL/MariaDB Database port in Linux. vi /etc/mysql/mariadb.conf.d/50-server.cnf Search for the line MYSQL, find port under this line, and replace port values accordingly. [mysq
1 min read
Linux System Monitoring Commands and Tools
Monitoring the performance and health of a Linux system is essential for maintaining its stability and optimizing resource utilization. Linux provides a variety of commands and tools to facilitate system monitoring, enabling administrators to track key metrics, identify potential issues, and ensure
5 min read
How to Migrating Data from MySQL to MariaDB?
Many times we developers and database administrators, want things like high performance, the ability to be open source, as well as additional features that MariaDB provides frequently move their data from MySQL to Maria DB. So Migrating data from MySQL to MariaDB can be done through several steps th
5 min read
How use Nmon and "Java Nmon Analyzer" for Monitor Linux Performance
Nmon or Nigelâs Performance Monitor is a tool that is used for the purpose of monitoring resources on Linux, x86_64, Mainframe, etc. With the help of Nmon, you can monitor CPUs, disks, memory, and a couple of other things. There are two modes of Nmon: Online mode: This is used for the purpose of rea
3 min read