|
NAMEmtop - Shows top mysql threadsSYNOPSISmtop [--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 DESCRIPTIONShows the MySQL commands consuming the greatest time. By default, only non-sleeping threads are shown, the --idle option shows idle threads. While running several keys will affect the operation of mtop. Hitting h or ? will show the available options.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. OPTIONSAll options can be abbreviated by their shortest unique abbreviation.
All options can be stored in initialization files. Command line options override options stored in the initialization file(s). The following files are checked for arguments: current direcotry .mtoprc, home directory .mtoprc, /usr/local/etc/mtoprc, /etc/mtoprc. Options in the former files override options in the later files. The format of the initialization file is one option per line. Options are specified just as they would be on the command line. They can be abbreviated and use the one or two hyphen syntax. Comments and blank lines are ignored. The following is an exmple .mtoprc file which sets a user filter to user1 and sets the refresh rate to one second: # Only look at 'user1' -fu user1 --seconds=1 # refresh every one seconds SETUPThe most convenient way to setup your system to use mtop is to create a database user called mysqltop which has no password. For security purposes, this user should have all privileges set to N except Process_priv which must be set to Y.To grant these privileges, execute the following from the MySQL command prompt For mysql 4.0.2 and greater: mysql> grant super, reload, process on *.* to mysqltop; mysql> grant super, reload, process on *.* to mysqltop@localhost; mysql> flush privileges; For mysql 3.x and 4.0.1: mysql> grant reload, process on *.* to mysqltop; mysql> grant reload, process on *.* to mysqltop@localhost; mysql> flush privileges; Notes:
Initially, mtop does not connect to a specific database. Most commands this program issues are non-database specific (SHOW FULL PROCESSLIST, SHOW VARIABLES, KILL id). However, when database-specific commands are needed, mtop will try to connect to the the required database and prompt for a username/password if the default one fails. To install mtop, run the following shell commands: perl Makefile.PL make make install The default {install_prefix} is /usr/local which means that mtop is installed in /usr/local/bin/. To change this, run: perl Makefile.PL --prefix={install_prefix} or modify the PREFIX line in Makefile.PL. Requires the following perl modules: Module Available At ------------ -------------------------------------------------------- Curses http://www.cpan.org/authors/id/WPS DBI Distributed as Bundle::DBI: http://www.cpan.org/authors/id/TIMB DBD::mysql http://www.cpan.org/authors/id/JWIED Getopt::Long (Distributed with Perl 5) Net::Domain Part of libnet: http://www.cpan.org/authors/id/GBARR/ AUTHORMarc Prewitt, Chelsea Networks <mprewitt@chelsea.net>Copyright (C) 2002 Marc Prewitt/Chelsea Networks, under the GNU GPL. mtop comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions; see the COPYING file for details. KNOWN BUGSThe cache hit ratio may look very low if your server receives more than 4 billion key_read_requests. This is due to a roll-over condition. If that number exceeds 4 billion and change, it rolls over to 1. The cache hit ratio is calculated as: 100 - (key_reads/key_read_requests) * 100.If you are really trying to focus on the cache hit ratio, flush the status variables with the mtop f command to reset both the key_reads and key_read_requests. Win2K telnet.exe - If you are using the Windows 2000 telnet program, it defaults to ansi mode which doesn't work well with curses (in my testing on Solaris 8). To work around this, set the terminal type to vt100. To do this, issue the following command from the telnet prompt before connecting to a host: set term vt100 Alternatively, you can manually set your TERM environment variable to vt100 after you are logged in. TODOOffer sorts by other columnsFor the 'More:' paging, it would be nice to support 'Less' behaviour. Add 'n' command and properly calculate number of lines on screen. $Id: mtop.PL,v 1.61 2004/09/12 22:22:03 mdprewitt Exp $ POD ERRORSHey! The above document had some coding errors, which are explained below:
Visit the GSP FreeBSD Man Page Interface. |