Commit Graph

39 Commits

Author SHA1 Message Date
dm-2
26522d20fd PT-2080 Add JSON logging to pt-kill (#543)
* Add JSON output support to pt-kill

Introduces new flags `--log-json` and `--log-json-fields` to control JSON output:
- `--log-json`: when combined with `--print`, outputs kill information in JSON format instead of plain text, with the same fields as the `kill_log` table when using `--log-dsn`
- `--log-json-fields`: when combined with `--log-json`, adds user-defined key-value pairs to the JSON document that is output (such as cluster name or hostname); parameter value is in the format of `key1:value1,key2:value2`

* Convert --log-json to write to file, remove dependency on --print, update docs

The `--log-json` parameter now takes a file path value, and writes JSON output to this file.

The `--print` parameter is now independent and does not need to be specified to use `--log-json`.

Docs updated for clarity.

* Add chksm to JSON output, make JSON key names consistent

- Adds chksm outout to JSON output to make it easier to group similar queries
- Moves chksm code so that it is always executed, is accessible within the `log-json` scope, and isn't duplicated
- Change JSON key names to consistently use uppercase letters at start of words, change `ts` to `Timestamp`

* Update docs to match changed field names

* Rename JSON parameter, output to STDOUT, fix tests, add test for --json, bug fix for --query-id

- `--json` parameter must now be used in conjunction with `--print`; JSON output replaces normal `--print` output when `--json` is also specified
- `--json` output is now sent to STDOUT instead of a specified file, as its new behaviour is to change the output format of `--print` instead of logging to a file
- Renamed `--log-json` and `--log-json-fields` parameters to `--json` and `--json-fields` to better represent their new behaviour
- Refactored checksum code to prevent test failures when `$query->{'Info'}` is empty
- Added test for `--json` and `--json-fields` parameters
- Fixed bug where specifying `--query-id` would cause errors when `$query->{'Info'}` is empty

* Fix typo: Unkown -> Unknown
2022-09-27 23:41:17 +03:00
Carlos Salguero
56f5202dbf WIP MySQL 8 support 2018-01-18 12:47:38 -03:00
Carlos Salguero
fec1a1f758 PT-167 pt-kill kills prepared statements w/o checking busy-time 2017-09-06 16:46:47 -03:00
Carlos Salguero
738f9809f8 PT-167 Still need to add tests
Description here
2017-09-04 12:03:36 -03:00
Daniel Nichter
09b1a373bd Clean up the new test. 2015-10-28 09:33:35 -07:00
frank-cizmich
976f645678 pt-kill fixed filter option lp1488685 2015-09-24 19:28:35 -03:00
Frank Cizmich
5251b00a9a used Transformers::make_checksum. Changed option to --query-id 2015-01-12 15:22:23 -02:00
Frank Cizmich
324a086d6a adds --fingerprint option for pt-kill - 1391240 2014-12-02 16:57:25 -02:00
Daniel Nichter
b54b4adb92 Use defaults-file in test config file to simulate user's setup. 2013-08-12 14:33:51 -07:00
Daniel Nichter
9d4f23fe53 Move --log-dsn tests from kill.t to log_dsn.t. Pass actual dsn, not retval of get_cxn_params() to Cxn. Add Sandbox::get_cnf(). 2013-08-12 14:19:57 -07:00
Daniel Nichter
c596331280 Move --log-dsn vars to outter scope to fix the rare Perl 5.8 scope-closure bug. 2013-08-12 09:11:53 -07:00
Brian Fraser
42484ecd10 Merged mysql-5.6-test-fixes and resolved conflicts 2012-12-19 13:47:54 -03:00
Brian Fraser
2bc72fc139 Fix for 1086259: pt-kill in non-daemon mode logs timestamps incorrectly 2012-12-04 18:05:32 -03:00
Daniel Nichter
9b97298721 Don't use -pmsandbox because 5.6 mysql cli warns that it's not safe. Plus, /tmp/PORT/use already adds --defaults-file=/tmp/PORT/my.sandbox.cnf. 2012-12-01 11:17:18 -07:00
Daniel Nichter
85a0616ec3 Redirect sys cmd 2>/dev/null in pt-kill tests to avoid false-positive errors. 2012-10-20 13:26:33 -06:00
Daniel Nichter
e85e647b86 Fix 'Lost connection to MySQL server during query' errors in pt-kill/kill.t. 2012-08-22 09:37:42 -06:00
Brian Fraser
f2016ded20 Really make a test 5.0 compatible 2012-07-19 13:40:54 -03:00
Brian Fraser
a964076cc2 t/pt-kill/kill.t: Make a test 5.0 compatible 2012-07-19 13:10:12 -03:00
Brian Fraser fraserb@gmail.com
27db3bc8cf Update the code to work on current trunk.
Changes for 941469 conflicted with this fix, so this had to be updated.
2012-07-14 23:31:05 -03:00
Daniel Nichter
554bd01f41 Stabilize some pt-kill tests. 2012-07-12 17:26:54 -06:00
Daniel Nichter
b1c6bba43a Test that pt-kill reconnects using new util/kill-mysql-process. Fix optional DSN by adding magical options rule. 2012-07-12 16:49:15 -06:00
Daniel Nichter
dab2e5c692 Add NAME_lc arg to Cxn to prevent it from being set. Use Cxn in pt-kill to retry lost connections. Add support for pt-kill DSN. 2012-07-12 13:52:52 -06:00
Baron Schwartz
649ee2c301 sleep 3 when --run-time 2, otherwise we get spurious failures 2012-06-05 11:56:56 -04:00
Daniel Nichter
a64bf961e8 Fix test counts. 2012-06-03 15:14:30 -04:00
Daniel Nichter
a2810a0ec1 Remove duplicate calls to Sandbox::ok(). 2012-06-03 14:38:21 -04:00
Daniel Nichter
bdbb66d22b Re-add calls to Sandbox::ok(). 2012-06-03 13:54:32 -04:00
Daniel Nichter
7e880b0808 Call Sandbox::box() in all tests that use Sandbox. 2012-06-03 12:59:56 -04:00
Brian Fraser fraserb@gmail.com
4e1dc7f727 pt-kill: Changes as per Daniel's review. 2012-05-01 14:14:48 -03:00
Brian Fraser fraserb@gmail.com
85756b0e94 pt-kill: Add a --log-dsn option.
This is customer issue 23049.
2012-05-01 03:27:11 -03:00
Daniel Nichter
a33031e6e4 Merge 2.0 r187. 2012-02-21 14:26:44 -07:00
Daniel Nichter
a17cbc8bd8 Add --filter to pt-kill and allow arbitrary --group-by. 2012-02-15 11:09:29 -07:00
Daniel Nichter
9383572742 Merge trunk r174. 2012-02-07 13:10:11 -07:00
Daniel Nichter
dd44a9b851 Add --test-matching to replace testing via STDIN/ARGV. 2012-01-25 11:37:10 -07:00
Daniel Nichter
0f1687608d Ignore SIGCHLD to avoid zombies. 2012-01-24 09:55:18 -07:00
Daniel Nichter
0c785d63b2 Fix pt-index-usage/basics.t by fixing pt-heartbeat/standard_options.t. Make pt-kill/basics.t dump output if tests fail. 2011-08-25 11:44:56 -06:00
Daniel Nichter
7526f97224 Fix and make tests more reliable. 2011-07-14 11:05:05 -06:00
Daniel Nichter
eb01431399 Change MaatkitTest to PerconaTest in all tool tests. Add stub tests for pt-align and pt-collect. 2011-07-12 16:56:55 -06:00
Daniel Nichter
8e11cd85b3 Change mk_tool::main() to pt_tool::main() in all tests. 2011-06-29 11:56:49 -06:00
Daniel Nichter
b4b6376be1 Add forked Maatkit tools in bin/ and their tests in t/. 2011-06-24 16:02:05 -06:00