percona-toolkit
percona-toolkit copied to clipboard
Print database name when logging pt-kill output to file
With multiple dbs in a single instance, its helpful to have pt-kill print the database name to the log file.
This addresses bug: https://blueprints.launchpad.net/percona-toolkit/+spec/pt-kill-log-database
With the suggested code change, an example output would show db name in the fourth column as shown below:
pt-kill --user=<user> --password=<password> --socket=<socket> --busy-time=20 --interval=15 --print --match-command=Query --daemonize --log <logfile>
# 2019-05-30T10:30:42 KILL 23063482 skyzer (Query 41 sec) SELECT domain FROM domains_data
# 2019-05-30T10:46:57 KILL 23080285 ddb2 (Query 20 sec) SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes'
# 2019-05-30T10:47:12 KILL 23080285 ddb2 (Query 35 sec) SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes'
# 2019-05-30T23:18:30 KILL 24551301 skyzer (Query 27 sec) DELETE FROM domains_data WHERE completed IS NULL
# 2019-05-30T23:22:00 KILL 24559692 skyzer (Query 25 sec) optimize table domains_data
# 2019-05-30T23:23:09 KILL 24559702 alph_co (Query 27 sec) UPDATE fus_settings SET settings_value=settings_value+1 WHERE settings_name='counter'