mtop [--host={mysql_host}] [--dbuser={mysql_user}]
[--password={mysqluser_pw}] [--seconds={refresh}] [--[no]idle]
[--filter-user={regex}] [--filter-host={regex}] [--filter-db={regex}]
[--filter-command={regex}] [--filter-state={regex}] [--filter-info={{regex}}]
[--fold-select-columns]
[--user={user}] [--manualrefresh] [--slow={seconds}] [--vs|veryslow={seconds}]
[--vvs|veryveryslow={seconds}]
mtop --help
mtop --version
Normally, run as a console program this will allow you to see errant or badly optimized queries as they will stay on the screen for a while. However, if you are hunting for short lived queries, running in the manualrefresh mode with a short refresh time will allow you to catch short lived queries as well.
The following keys are active while mtop is running:
q - quit
? - help
Filtering/display
s - change the number of seconds to delay between updates
m - toggle manual refresh mode on/off
d - filter display with regular expression (user/host/db/command/state/info)
F - fold/unfold column names in select statement display
h - display process for only one host
u - display process for only one user
i - toggle all/non-Sleeping process display
o - reverse the sort order
Control/Detail
k - kill processes; send a kill to a list of ids
e - explain a process; show query optimizer info
z - zoom in on a process; show sql statement detail
f - flush stats (reset show status variables)
t - show mysqld stats (show status/mysqladmin ext)
T - show short/important status
v - show mysqld variables (show variables/mysqladmin vars)
r - show replication status for master/slaves
Main Screen
The main query screen shows the following information as well as the currently active queries (explanations are from the MySQL online manual and references refer to the section in the manual where the explanation came from):
Statistics/Variables
When viewing the stats screen (t), the screen will refresh until a key is pressed at which point you will return to the main screen. The bottom of the stats screen is denoted with a line containing ---. If you do not see that line, resize your screen until you do.
The statistics screen has the following format:
Stat: total [avg per sec / instant per sec ]
For example:
Questions: 720,672 [30/12]
The short/important status screen is a list of recommendations from the MySQL manual.
The first number is the total since startup or the last 'flush status'. The second number is the number per second since startup or flush. The last is the number per second since the last screen refresh.
The variables screen only shows the information once and returns to the main screen as the variables do not change after server startup.
Replication
The replication monitor screen looks for a master or slave server running on the currently monitored mysqld. If a master server is found, it then tries to connect to each slave connected to the master. Replication is shown for all masters and slaves found. Offsets from the master for each of the slaves is shown. Note: the offset may be less than zero because the slave position is checked after the master position. The offset shown is the number of queries in the binlog that the slave has to process before being caught up with the master.