How to monitor MySQL in real-time with mytop

Mytop is a top-like realtime command line based monitoring system for MySQL. It is written by Jeremy Zawodny, and is available for free download. It runs on most UNIX-based systems, and most definitely on Linux machines. This kind of real-time monitoring can be very useful when administering a MySQL server.

You need a working MySQL server and a few Perl modules such as DBI, DBD::mysql, Term::ReadKey, and Getopt::Long to be able to use mytop. You can download the source code version of mytop from the project’s website, or you can get a pre-built binary package for your distribution. I know that there are packages for Fedora/Redhat and for Ubuntu systems. You should be able to find them pretty easily on the web. Once you get the binary version of mytop install it.

http://jeremy.zawodny.com/mysql/mytop/

wget http://jeremy.zawodny.com/mysql/mytop/mytop-1.6.tar.gz
tar -zxf mytop-1.6.tar.gz
cd mytop*
perl Makefile.PL
make test
make
make install

Once you have installed mytop you can check if it is working using the following command:

# mytop -h dbserver -u dbuser -p dbpassword

MySQL on dbserver (5.0.37) up 50+17:53:46 [13:20:38]
Queries: 2.5G qps: 609 Slow: 0.0 Se/In/Up/De(%): 01/00/00/00

Key Efficiency: 99.8% Bps in/out: 0.0/ 0.0

Id User Host/IP DB Time Cmd Query or State
— —- ——- — —- — ———-
9570443 dbuser 192.168.10.9 appdb 0 Prepar
9575575 dbuser 192.168.10.9 appdb 0 Sleep
9576920 dbuser 192.168.10.9 appdb 0 Sleep
9593343 dbuser 192.168.10.4 appdb 0 Sleep
9601720 dbuser 192.168.10.3 appdb 0 Query show full process
9574728 dbuser 192.168.10.9 appdb 1 Sleep
9575771 dbuser 192.168.10.9 appdb 1 Sleep
9579103 dbuser 192.168.10.9 appdb 1 Sleep
9579962 dbuser 192.168.10.4 appdb 1 Sleep
9581070 dbuser 192.168.10.4 appdb 1 Sleep
9585516 dbuser 192.168.10.4 appdb 1 Sleep
9585518 dbuser 192.168.10.4 appdb 1 Sleep
9597503 dbuser 192.168.10.4 appdb 1 Sleep
9597952 dbuser 192.168.10.4 appdb 1 Sleep
9599442 dbuser 192.168.10.9 appdb 1 Sleep

Replace dbserver, dbuser, and dbpassword with the correct credentials of your MySQL server. This ought to get you off the blocks with mytop. You can read up this documentation if you want to see a list of options supported by mytop

g33kadmin

I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.