|
NAMEmkill - Kills slow queriesSYNOPSISmkill [--host={mysql_host}] [--dbuser={mysql_user}] [--password={mysqluser_pw}] [--filter-user={regex}] [--filter-host={regex}] [--filter-db={regex}] [--filter-command={regex}] [--filter-state={regex}] [--filter-info={{regex}}] [--user={user}] [--slow={seconds}] [--daemonize] [--test] mkill --help mkill --version DESCRIPTIONThis is an alpha version of this program. Please let me know what you think and what additional features would be nice. Future version will most likely perform the same but have different output. One idea i've been thinking about is letting you specify filters which short perl snippets instead of just regexes.This program kills long running queries based on several criteria including query time, host, user, database, state, and query content. The following keys are active while mkill is running: q - quit A log of killed queries is sent to STDERR, watched queries are sent to STDOUT. A typical command line would be: mkill -sl 180 -fi 'select.*from bad_table' > /var/log/mkill.out 2> /var/log/mkill.kill OPTIONSAll options can be abbreviated by their shortest unique abbreviation.
FILTER OPTIONS
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 .mkillc, home directory .mkillc, /usr/local/etc/mkillc, /etc/mkillc. 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 .mkillc file which kills any 'select' statements from 'user1' which last more than 120 seconds. # Only kill 'user1' 'select' queries > 120 seconds -fu user1 -filter-info='select' --slow=1 # refresh every one seconds SETUPThe most convenient way to setup your system to use mkill is to create a database user called mysqlkill 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,process on *.* to mysqlkill; mysql> grant super,process on *.* to mysqlkill@localhost; mysql> flush privileges; For mysql 3.x and 4.0.1: mysql> grant process on *.* to mysqlkill; mysql> grant process on *.* to mysqlkill@localhost; mysql> flush privileges; Notes:
Initially, mkill 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, mkill will try to connect to the the required database and prompt for a username/password if the default one fails. To install mkill, run the following shell commands: perl Makefile.PL make make install The default {install_prefix} is /usr/local which means that mkill 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 ------------ -------------------------------------------------------- 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) 2003 Marc Prewitt/Chelsea Networks, under the GNU GPL. mkill 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 BUGS$Id: mkill.PL,v 1.6 2004/09/12 21:19:12 mdprewitt Exp $ The get char routines used to quit the program currently require the user to hit the RETURN key on the keyboard after entry. This will soon be fixed. POD ERRORSHey! The above document had some coding errors, which are explained below:
Visit the GSP FreeBSD Man Page Interface. |