Skip to content
Home » How to Install Mytop?

How to Install Mytop?

  • by

As a sysadmin, you need a tool to monitor the MariaDB database, and one of the tools you can use is mytop.

 

Problem

How to install mytop?

 

Solution

Mytop is an open-source utility developed by Jeremy Zawodny with Perl for real-time monitoring of MySQL/MariaDB databases. To install this tool, use the commands below:

wget https://jeremy.zawodny.com/mysql/mytop/mytop-1.6.tar.gz
tar -zxvf mytop-1.6.tar.gz 
cd mytop-1.6/
perl Makefile.PL 
make
make test
sudo make install

 

To run this tool, use the format below:

mytop --prompt -d db_name

 

For example, if you want to monitor the Zabbix database, then use the command below:

mytop --prompt -d zabbix

 

Warning
But, if you want to use another user, you have to use the command below:

mytop --prompt -u zabbix_user -d zabbix

 

By default, Mytop uses the root user to enter the database, then enter the password from the root user, and you should see a display like the one below:

View of mytop application

 

You see from the image above, it looks like the top command in Linux. The following is a brief explanation of what the image above looks like:

  • The first line shows the version of the MariaDB Database and the uptime of the server.
  • The second line shows the number of queries that have been processed on the server (Queries), the average number of queries per second (qps), the number of slow queries (Slow), and the percentage of Select, Insert, Update, and Delete queries (Se/In/Up/De(%)).
  • The third line shows the current value since the last mytop refresh, which defaults to 5 seconds. The first field is the number of queries per second. The second value is the number of slow queries per second. The threads segment indicates there are a total of 32 connected threads, 1 is active (the others are sleeping), and there are 0 threads in the thread cache. The last field in the third line shows the query percentages, like in the previous line, but since last mytop refresh.
  • The fourth line shows crucial buffer efficiency (the frequency of key reads from the buffer instead of the disk) and the total number of bytes that MySQL has both sent and received, including data from the last mytop cycle. Key Efficiency: 100.0% indicates that all keys are read from the buffer, not from the disk. Bps in/out: 0.1/5.4 shows that since startup, MySQL has averaged 0.1kbps of inbound traffic and 5.4kbps for outbound traffic. Now in/out shows the traffic again, but since last mytop refresh.
  • The next line up to the last line shows a list of current MySQL threads, sorted according to their idle time (least idle first).

If you want to see more details about a query, then you can press the f button, and you will see a display like the one below:

Type the f button to get more details

 

Select the ID number for which you want to display the query in detail, for example, number 65, then type number 65 and press the Enter button, and then there will be a display like the one below:

Display the query in more detail

 

If you want to see an explanation of a query, then type the e button as in the image below, then there will be a display like the one below:

Type the ID number to explain the query

 

Type the ID number you want to explain, and after that, press the Enter key. If you want to see the command view, press the c button, then there will be a display like below:

Display the command view

 

The Command column displays the type of command or query that was executed, and the following is a brief explanation:

  • – The Total column represents the overall count of that type of command executed since the server began.
  • – The Last column indicates how many of that command type were executed since the last mytop refresh
  • – The Pct column indicates the equivalent percentage.

 

If you want to exit the mytop application, press the q button. If you want to enter the mytop application without having to type a password, you can create a .mytop file. Type the command:

vi ~/.mytop

 

After that, copy the script below, assuming the Zabbix database that you want to monitor uses the mytop application:

host=localhost
db=zabbix
user=root
pass=qwerty
delay=5
port=3306
socket=
batchmode=0
color=1
idle=1

 

After that, type the mytop command, and the mytop application should immediately display the mytop application without you having to write arguments and passwords, as in the image below:

Run the mytop tool without arguments and a password

 

You should only make a user a viewer if you are afraid that others will see your database password.

 

Note

Regrettably, this application is no longer under development, and the final version available is 1.6 from 2007. Nonetheless, after I use this tool in November 2025, it remains effective for monitoring MySQL/MariaDB databases.

 

References

jeremy.zawodny.com
digitalocean.com
tecmint.com
whplus.com
geeksforgeeks.org

image_pdfimage_print
Visited 1 times, 1 visit(s) today
Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *