-
Notifications
You must be signed in to change notification settings - Fork 5
/
README
194 lines (129 loc) · 6.01 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
NAME
mysql-genocide - Parallel operation on MySQL processlist
SYNOPSIS
mysql-genocide [OPTIONS] [FILTER]
Options:
-h, --help Show help.
Connection:
-h, --host=name Connect to host.
-P, --port=# Port number to use for connection.
-D, --database=name Database to use.
-u, --user=name User for login if not current user.
-p, --password=name Password to use when connecting to server.
Filters:
-e, --exclude Exclude queries by different criteria
-s, --selects-only Exclude everything but selects
-t, --min-time=# Exclude queries with exec time lower than #
-T, --timeout Exclude queries with exec time lower than query time hint
-l, --limit=# Only take first # lines
-g, --placeholder Replace values in queries by placeholders
-d, --distinct Only keep the first occurence of the same query
--sort Sort result
Actions:
-L, --list Output list of queries
-K, --kill Kill every matched threads
-S, --stats Show some stats about processlist
-i, --interval[=#] Repeat the command at regular interval
OPTIONS
--help Print a brief help message and exits.
--host, --port, --database, --user, --password
See mysql cli help for more information on those parameters.
--exclude=[!]name
Exclude from the running thread list queries matching the
argument. This parameter can be repeated several times to
exclude different kinds of queries. If you prefix the argument
with an exclamation mark (!), all thread not matching this
argument will be excluded. Allowed parameters are:
select, insert, replace, update, delete, create, drop, alter
Exclude SQL query which command is of the same name.
write
Exclude every SQL query doing write operation (insert, replace,
update, delete).
other
Exclude SQL query which are none of the above type.
sleep
Exclude all sleeping threads
system
Exclude thread ran by the system (often used for replication
threads)
user=<user>
Exclude threads ran by given mysql username.
db=<db>
Exclude threads using given database.
state=<state>
Exclude threads in given state.
See
<http://dev.mysql.com/doc/refman/5.0/en/general-thread-states.ht
ml> for the list of possible states
command=<command>
Exclude threads using given command.
See
<http://dev.mysql.com/doc/refman/5.0/en/thread-commands.html>
for the list of possible commands.
--selects-only
This is equivalent to: --exclude=write --exclude=other
--exclude=sleep --exclude=system.
--min-time=#
Exclude queries with execution time lower than given parameter.
--timeout
Keep only queries with a timeout provided and with an execution
time which exceeded this timeout. The timeout can be provided
with the query in a comment like this:
SELECT /* timeout:40 */ * FROM table;
Timeout is expressed in second.
--limit=#
Take first # threads and excludes others.
--placeholder
Will try to make queries more generic by replacing all values by
either "i" for numbers or "s" for strings.
--distinct
Keep only the first query from group of identical queries and
exlude others.
Note: If you use this option with --placeholder, queries that
would differ only by values used will become identical. This is
useful to distinct big type of queries.
--sort[=name]
Sort matched queries by parameter given as argument.
Allowed parameters are as follow:
concurrency or c
Sort queries by most repeated ones.
time or t
Sort queries by longer execution time.
--list[=template]
Output the result to the terminal.
The default output format can be changed by supplying a template
with desired field.
Available fields are: Id, User, Command, State, Db, Host, Time,
Info, Group, Concurrency, QType, Timeout
Default template is: <Id> <User> <Db> <Time> <Info>
--kill Kill every threads that match the given filters.
--stats Show statistics about queries matched by filters.
--interval[=#]
Repeat the command at regular interval. Interval in second can
be specified as argument. If not specified, default interval is
5 seconds.
DESCRIPTION
mysql-genocide helps you play with big MySQL processlists. It can filter
it using different criterias like execution time, query type, user or
regexp matching of the SQL query etc. Actions can then be peformed on
the result like killing, sorting or generating statistics.
EXAMPLES
Kill all selects with execution time geater than 60 seconds:
mysql-genocide --selects-only --min-time 60 --kill
Same as before but limited on queries matching a pattern:
mysql-genocide -s -t 60 -K 'FROM user '
Kill all queries timed out:
mysql-genocide --timeout --kill
Replace queries values by placeholders and group identical queries
together, sort them by most concurrent and keep only the 10 most
concurent ones:
mysql-genocide --placeholder --group --sort concurrency --limit 10 --list
SCRIPT CATEGORIES
Unix/System_administration
PREREQUISITES
This script requires the "DBD::mysql", "Getopt::Long" and "Pod::Usage"
modules.
OSNAMES
any
AUTHOR
Olivier Poitrey <rs@dailymotion.com>