Configure setup_instruments (for the mutex page) if possible on startup, and restore...
[pstop.git] / README.md
1 ## pstop
2
3 pstop - a top-like program for MySQL
4
5 pstop is a program which collects information from MySQL 5.6+'s
6 performance_schema database and uses this information to display
7 server load in real-time. Data is shown by table or filename and
8 the metrics also show how this is split between select, insert,
9 update or delete activity.  User activity is now shown showing the
10 number of different hosts that connect with the same username and
11 the actiity of those users.
12
13 ### Installation
14
15 Install and update this go package with `go get -u github.com/sjmudd/pstop`.
16
17 Note if you are looking for binaries for pstop then look here
18 http://gobuild.io/github.com/sjmudd/pstop as a possible location.
19 I have not tried this service but it looks ok.
20
21 ### Dependencies
22
23 The following Non-core Go dependencies are:
24 * github.com/sjmudd/mysql_defaults_file for connecting to MySQL via
25 a defaults file.
26 * github.com/nsf/termbox-go a library for creating cross-platform
27 text-based interfaces.
28
29 ### Configuration
30
31 Access to MySQL can be made by one of the following methods:
32 * Default: use a defaults-file named `~/.my.cnf`.
33 * use an explicit defaults-file with `--defaults-file=/path/to/.my.cnf`.
34 * connect to a host with `--host=somehost --port=999 --user=someuser --password=somepass`, or
35 * connect via a socket with `--socket=/path/to/mysql.sock --user=someuser --password=somepass`
36
37 The user if not specified will default to the contents of `$USER`.
38 The port if not specified will default to 3306.
39
40 ### Grants
41
42 `pstop` needs `SELECT` access to `performance_schema` tables. It
43 will not run if access to the required tables is not available.
44
45 setup_instruments: To view the Mutex page it is likely you will need
46 to change the configuration of setup_instruments. pstop needs UPDATE
47 rights on this table to do that. If the pstop user does not have
48 this right then the configuration will not be modified and you may see
49 no data.  When pstop stops it will restore the setup_instruments
50 configuration back to its original settings if it successfully
51 updated the table when starting up.
52
53 ### Screens
54
55 pstop has 5 different screens which get updated by default every second.
56 * Latency mode: order table activity by the time waiting to perform operations on them.
57 * Ops (operations) mode: order table activity by the number of operations MySQL performs on them.
58 * I/O mode: show where MySQL is spending it's time in file I/O.
59 * Locks mode: show order based on table locks
60 * User mode: show ordering based on how long users are running
61 queries, or the number of connections they have to MySQL. This is
62 really missing a feature in MySQL (see: http://bugs.mysql.com/75156)
63 to provide higher resolution query times than seconds. It gives
64 some info but if the queries are very short then the integer runtime
65 in seconds makes the output far less interesting. Total idle time is also
66 shown as this gives an indication of perhaps overly long idle queries,
67 and the sum of the values here if there's a pile up may be interesting.
68 * Mutex mode: show the ordering by mutex latency (currently requires correct P_S setup).
69
70 You can change the polling interval and switch between modes (see below).
71
72 ### Keys
73
74 The following keys allow you to navigate around the different pstop displays or to change it's behaviour.
75
76 * h - gives you a help screen.
77 * - - reduce the poll interval by 1 second (minimum 1 second)
78 * + - increase the poll interval by 1 second
79 * q - quit
80 * t - toggle between showing the statistics since resetting pstop started or you explicitly reset them (with 'z') [REL] or showing the statistics as collected from MySQL [ABS].
81 * z - reset statistics. That is counters you see are relative to when you "reset" statistics.
82 * <tab> - change display modes between: latency, ops, file I/O, lock, user and mutex modes.
83 * left arrow - change to previous screen
84 * right arrow - change to next screen
85
86 ### See also
87
88 See also:
89 * [BUGS](https://github.com/sjmudd/pstop/blob/master/BUGS) currently known issues
90 * [NEW_FEATURES](https://github.com/sjmudd/pstop/blob/master/NEW_FEATURES) which describe things that probably need looking at
91 * [screen_samples.txt](https://github.com/sjmudd/pstop/blob/master/screen_samples.txt) provides some sample output from my own system.
92
93 ### Contributing
94
95 This program was started as a simple project to allow me (Simon) to learn
96 go, which I'd been following for a while, but hadn't used in earnest.
97 This probably shows in the code so suggestions on improvement are
98 most welcome.
99
100 You may find "Contributing to Open Source Git Repositories in Go"
101 by Katrina Owen to be useful:
102 https://blog.splice.com/contributing-open-source-git-repositories-go/
103
104 ### Licensing
105
106 BSD 2-Clause License
107
108 ### Feedback
109
110 Feedback and patches welcome. I am especially interested in hearing
111 from you if you are using pstop, or if you have ideas of how I can
112 better use other information from the performance_schema tables to
113 provide a more complete vision of what MySQL is doing or where it's
114 busy.
115
116 Simon J Mudd
117 <sjmudd@pobox.com>
118
119 ### Code Documenton
120 [godoc.org/github.com/sjmudd/pstop](http://godoc.org/github.com/sjmudd/pstop)