Previous Section  < Day Day Up >  Next Section

B.3 Configuration and Usage

mytop's behavior is controlled by a combination of command-line arguments, configuration file options, and runtime keystrokes. Most command-line arguments appear in single letter (-p) and longer GNU-style (--password) forms. Table B-1 lists the keystrokes, command-line arguments, configuration file directives, and the actions they perform.

Upon startup, mytop looks for a ~/.mytop. If it finds one, it reads in the settings and uses them as defaults, which are then overridden by any command-line arguments. The configuration file format is composed of key/value pairs, one per line. A sample file might look like this:

user=jzawodn

pass=blah!db

host=localhost

Most of the command-line arguments have a counterpart option in the configuration file. Future versions of mytop are expected to read MySQL's /etc/my.cnf and ~/.my.cnf as well, possibly deprecating ~/.mytop at some point.

Table B-1. mytop configuration and control

Key

Argument(s)

Config file

Action

?

  

Display help screen

 

--batch or --batchmode

batchmode=1

Run in batch (noninteractive) mode. Useful when called from cron or another script.

c

-m=cmd or --mode=cmd

mode=cmd

Command summary view.

C

--color or --nocolor

color=[0|1]

Use colors in the display. (Requires the Term::ANSIColor module.) The key toggles color on/off.

d

 

filter_db=dbname

Show threads using one specific database.

 

-d or --database

db=dbname

Connect to this database.

e

  

Explain the query a thread is running.

f

  

Show the full query a thread is executing.

F

  

Unfilter the display; return to defaults.

 

-h or --host

host=hostname

Specify the host on which MySQL is running; default is localhost.

h

  

Show only connections from a particular host.

H

--header or--noheader

 

Display the header mytop's display (key toggles the header display).

i

-i or --idle

idle=[0|1]

Filter idle (sleeping) threads from the display. Key toggles this.

I

-m= or --mode=innodb

mode=innodb

Show InnoDB status.

k

  

Kill a thread.

m

-m= or --mode=[qps|top|cmd|innodb]

mode=[qps|top|cmd|innodb]

Mode switch. Cycle between thread view, queries per second, and command summary.

o

--sort=[0|1]

sort=[0|1]

Reverse the sort order. Default is ascending based on time.

p

  

Pause the display. Any key resumes.

 

-p or --password

pass=password

Connect using this password.

 

--prompt

prompt=[0|1]

Prompt for password interactively.

q

  

Quit mytop.

r

  

Reset status counters (via FLUSH STATUS).

R

-r or --resolve

resolve=[0|1]

Resolve IP addresses into hostnames. This is useful when MySQL is configured with skip-name-resolve.

s

-s or --delay

delay=number

Adjust the refresh interval.

S

-m= --mode=status

mode=status

Switch to SHOW STATUS mode.

 

-S or --socket

socket=/path/to/socket

Specify the socket to use when connecting to localhost.

t

-m= or --mode=top

mode=top

Switch to thread view (the default).

u

 

filter_user=username

Show only a particular user's threads.

 

-u or --user

user=username

Connect as this user.

V

  

Switch to SHOW VARIABLES mode.

:

  

Enter a complex command.

    Previous Section  < Day Day Up >  Next Section