NAMEoak-kill-slow-queries: terminate long running queries
SYNOPSISKill queries running longer than 60 seconds:
oak-kill-slow-queries --slow-query-seconds=60Kill queries running longer than 60 seconds provided they're not invoked by user 'root':
oak-kill-slow-queries --slow-query-seconds=60 --skip-rootKill queries running longer than 60 seconds provided they're not invoked by user 'myuser':
oak-kill-slow-queries --slow-query-seconds=60 --skip-user=myuserKill any query running longer than 60 seconds and which was invoked by user 'myuser'
oak-kill-slow-queries --slow-query-seconds=60 --filter-user=myuserSame as above; doesn't perform the KILL, just prints out the statement:
oak-kill-slow-queries --slow-query-seconds=60 --filter-user=myuser --print-onlySame as above, short form; verbose:
oak-kill-slow-queries -l 60 -f myuser --print-only -vSame as above, provide connection parameters, prompt for password:
oak-kill-slow-queries --user=root --ask-pass --socket=/tmp/mysql.sock -l 60 -f myuserSame as above, use defaults file:
oak-kill-slow-queries --defaults-file=/home/myuser/.my-oak.cnf -l 10 -f myuser
DESCRIPTIONTerminate long running queries: this utility can terminate queries based on running time and invoking user. It utilizes MySQL's KILL QUERY command, which requires the SUPER privilege. Queries can be terminated per given user, or can be skipped per given user. Only the queries get killed, the connections itself is not affected. Expect exceptions/errors on your client when the queries are killed.
Prompt for password.--defaults-file=DEFAULTS_FILE
Read from MySQL configuration file. Overrides --user, --password, --socket, --port.
Configuration needs to be in the following format:
Only kill queries by by given user. Do not kill queries by other users-H HOST, --host=HOST
MySQL host (default: localhost)-l SLOW_QUERY_SECONDS, --slow-query-seconds=SLOW_QUERY_SECONDS
Number of seconds after which a query is considered slow-k SKIP_USER, --skip-user=SKIP_USER
Do not kill queries invoked by given user-p PASSWORD, --password=PASSWORD
MySQL password-P PORT, --port=PORT
TCP/IP port (default: 3306)--print-only
Do not execute. Only print statement-r, --skip-root
Do not kill queries by 'root' (same as --skip-user=root)-S SOCKET, --socket=SOCKET
MySQL socket file. Only applies when host is localhost-u USER, --user=USER
MySQL user-v, --verbose
Print user friendly messages
ENVIRONMENTRequires MySQL 5.0 or newer, python 2.3 or newer. python-mysqldb must be installed in order to use this tool. You can
apt-get install python-mysqldbor
yum install mysql-python
LICENSEThis tool is released under the BSD license.
Copyright (c) 2008 - 2010, Shlomi Noach All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.