Merge lp:~percona-toolkit-dev/percona-toolkit/pt-ms-pt-stalk-standard-mysql-options into lp:percona-toolkit/2.2
- pt-ms-pt-stalk-standard-mysql-options
- Merge into 2.2
Proposed by
Daniel Nichter
| Status: | Merged |
|---|---|
| Approved by: | Daniel Nichter |
| Approved revision: | 525 |
| Merged at revision: | 551 |
| Proposed branch: | lp:~percona-toolkit-dev/percona-toolkit/pt-ms-pt-stalk-standard-mysql-options |
| Merge into: | lp:percona-toolkit/2.2 |
| Diff against target: |
714 lines (+353/-45) (has conflicts) 9 files modified
bin/pt-mysql-summary (+134/-34) bin/pt-stalk (+108/-3) bin/pt-summary (+2/-2) lib/bash/collect_mysql_info.sh (+6/-2) lib/bash/mysql_options.sh (+68/-0) lib/bash/parse_options.sh (+2/-2) lib/bash/report_mysql_info.sh (+1/-0) t/lib/bash/mysql_options.sh (+30/-0) t/pt-stalk/pt-stalk.t (+2/-2) Text conflict in bin/pt-stalk |
| To merge this branch: | bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-ms-pt-stalk-standard-mysql-options |
| Related bugs: | |
| Related blueprints: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Daniel Nichter | Approve | ||
| Brian Fraser (community) | Approve | ||
|
Review via email:
|
|||
Commit message
Description of the change
To post a comment you must log in.
- 521. By Brian Fraser
-
Minor fixes for compat
Revision history for this message
| Brian Fraser (fraserbn) : | # |
review:
Approve
- 522. By Brian Fraser
-
Rearrange mysql options so that --defaults-file is always first, and remove default: localhost from pt-ms and pt-stalk, since parse_options.sh deals with defaults + config files for mysql options poorly
- 523. By Brian Fraser
-
update-samples on pt-ms
- 524. By Brian Fraser
-
Removed test for hosts's default
- 525. By Daniel Nichter
-
Alphabetize pt-mysql-summary and pt-stalk options.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
| 1 | === modified file 'bin/pt-mysql-summary' |
| 2 | --- bin/pt-mysql-summary 2013-03-09 16:57:54 +0000 |
| 3 | +++ bin/pt-mysql-summary 2013-03-09 18:49:22 +0000 |
| 4 | @@ -347,14 +347,14 @@ |
| 5 | |
| 6 | if [ "$next_opt_is_val" ]; then |
| 7 | next_opt_is_val="" |
| 8 | - if [ $# -eq 0 ] || [ $(expr "$opt" : "-") -eq 1 ]; then |
| 9 | + if [ $# -eq 0 ] || [ $(expr "$opt" : "\-") -eq 1 ]; then |
| 10 | option_error "$real_opt requires a $required_arg argument" |
| 11 | continue |
| 12 | fi |
| 13 | val="$opt" |
| 14 | opt_is_ok=1 |
| 15 | else |
| 16 | - if [ $(expr "$opt" : "-") -eq 0 ]; then |
| 17 | + if [ $(expr "$opt" : "\-") -eq 0 ]; then |
| 18 | if [ -z "$ARGV" ]; then |
| 19 | ARGV="$opt" |
| 20 | else |
| 21 | @@ -451,6 +451,61 @@ |
| 22 | # ########################################################################### |
| 23 | |
| 24 | # ########################################################################### |
| 25 | +# mysql_options package |
| 26 | +# This package is a copy without comments from the original. The original |
| 27 | +# with comments and its test file can be found in the Bazaar repository at, |
| 28 | +# lib/bash/mysql_options.sh |
| 29 | +# t/lib/bash/mysql_options.sh |
| 30 | +# See https://launchpad.net/percona-toolkit for more information. |
| 31 | +# ########################################################################### |
| 32 | + |
| 33 | + |
| 34 | +set -u |
| 35 | + |
| 36 | +mysql_options() { |
| 37 | + local MYSQL_ARGS="" |
| 38 | + if [ -n "$OPT_DEFAULTS_FILE" ]; then |
| 39 | + MYSQL_ARGS="--defaults-file=$OPT_DEFAULTS_FILE" |
| 40 | + fi |
| 41 | + if [ -n "$OPT_PORT" ]; then |
| 42 | + MYSQL_ARGS="$MYSQL_ARGS --port=$OPT_PORT" |
| 43 | + fi |
| 44 | + if [ -n "$OPT_SOCKET" ]; then |
| 45 | + MYSQL_ARGS="$MYSQL_ARGS --socket=$OPT_SOCKET" |
| 46 | + fi |
| 47 | + if [ -n "$OPT_HOST" ]; then |
| 48 | + MYSQL_ARGS="$MYSQL_ARGS --host=$OPT_HOST" |
| 49 | + fi |
| 50 | + if [ -n "$OPT_USER" ]; then |
| 51 | + MYSQL_ARGS="$MYSQL_ARGS --user=$OPT_USER" |
| 52 | + fi |
| 53 | + if [ -n "$OPT_PASSWORD" ]; then |
| 54 | + MYSQL_ARGS="$MYSQL_ARGS --password=$OPT_PASSWORD" |
| 55 | + fi |
| 56 | + |
| 57 | + echo $MYSQL_ARGS |
| 58 | +} |
| 59 | + |
| 60 | +arrange_mysql_options() { |
| 61 | + local opts="$1" |
| 62 | + |
| 63 | + local rearranged="" |
| 64 | + for opt in $opts; do |
| 65 | + if [ "$(echo $opt | awk -F= '{print $1}')" = "--defaults-file" ]; then |
| 66 | + rearranged="$opt $rearranged" |
| 67 | + else |
| 68 | + rearranged="$rearranged $opt" |
| 69 | + fi |
| 70 | + done |
| 71 | + |
| 72 | + echo "$rearranged" |
| 73 | +} |
| 74 | + |
| 75 | +# ########################################################################### |
| 76 | +# End mysql_options package |
| 77 | +# ########################################################################### |
| 78 | + |
| 79 | +# ########################################################################### |
| 80 | # tmpdir package |
| 81 | # This package is a copy without comments from the original. The original |
| 82 | # with comments and its test file can be found in the Bazaar repository at, |
| 83 | @@ -788,7 +843,6 @@ |
| 84 | echo "internal::oom_of_$pid $oom" >> "$variables_file" |
| 85 | done |
| 86 | |
| 87 | - pids="$pids" |
| 88 | pids="$(echo $pids | sed -e 's/ /,/g')" |
| 89 | ps ww -p "$pids" 2>/dev/null |
| 90 | else |
| 91 | @@ -930,8 +984,13 @@ |
| 92 | collect_mysqld_executables () { |
| 93 | local mysqld_instances="$1" |
| 94 | |
| 95 | + local ps_opt="cmd=" |
| 96 | + if [ "$(uname -s)" = "Darwin" ]; then |
| 97 | + ps_opt="command=" |
| 98 | + fi |
| 99 | + |
| 100 | for pid in $( grep '/mysqld' "$mysqld_instances" | awk '/^.*[0-9]/{print $1}' ); do |
| 101 | - ps -o cmd -p $pid | sed -e 's/^\(.*mysqld\) .*/\1/' | grep -v '^CMD$' |
| 102 | + ps -o $ps_opt -p $pid | sed -e 's/^\(.*mysqld\) .*/\1/' |
| 103 | done | sort -u |
| 104 | } |
| 105 | |
| 106 | @@ -2320,6 +2379,7 @@ |
| 107 | |
| 108 | section "Configuration File" |
| 109 | local cnf_file="$(get_var "pt-summary-internal-Config_File_path" "$dir/mysql-variables")" |
| 110 | + |
| 111 | if [ -n "${cnf_file}" ]; then |
| 112 | name_val "Config File" "${cnf_file}" |
| 113 | pretty_print_cnf_file "$dir/mysql-config-file" |
| 114 | @@ -2376,6 +2436,14 @@ |
| 115 | # Prepending SIG to these doesn't work with NetBSD's sh |
| 116 | trap sigtrap HUP INT TERM |
| 117 | |
| 118 | + local MYSQL_ARGS="$(mysql_options)" |
| 119 | + EXT_ARGV="$(arrange_mysql_options "$EXT_ARGV $MYSQL_ARGS")" |
| 120 | + |
| 121 | + # Check if mysql and mysqldump are there, otherwise bail out early. |
| 122 | + # But don't if they passed in --read-samples, since we don't need |
| 123 | + # a connection then. |
| 124 | + [ "$OPT_READ_SAMPLES" ] || check_mysql |
| 125 | + |
| 126 | local RAN_WITH="--sleep=$OPT_SLEEP --databases=$OPT_DATABASES --save-samples=$OPT_SAVE_SAMPLES" |
| 127 | |
| 128 | _d "Starting $0 $RAN_WITH" |
| 129 | @@ -2442,11 +2510,6 @@ |
| 130 | exit 0 |
| 131 | fi |
| 132 | |
| 133 | - # Check if mysql and mysqldump are there, otherwise bail out early. |
| 134 | - # But don't if they passed in --read-samples, since we don't need |
| 135 | - # a connection then. |
| 136 | - [ "$OPT_READ_SAMPLES" ] || check_mysql |
| 137 | - |
| 138 | main "${@:-""}" |
| 139 | fi |
| 140 | |
| 141 | @@ -2462,7 +2525,7 @@ |
| 142 | |
| 143 | =head1 SYNOPSIS |
| 144 | |
| 145 | -Usage: pt-mysql-summary [OPTIONS] [-- MYSQL OPTIONS] |
| 146 | +Usage: pt-mysql-summary [OPTIONS] |
| 147 | |
| 148 | pt-mysql-summary conveniently summarizes the status and configuration of a |
| 149 | MySQL database server so that you can learn about it at a glance. It is not |
| 150 | @@ -2498,7 +2561,7 @@ |
| 151 | To use, simply execute it. Optionally add a double dash and then the same |
| 152 | command-line options you would use to connect to MySQL, such as the following: |
| 153 | |
| 154 | - pt-mysql-summary -- --user=root |
| 155 | + pt-mysql-summary --user=root |
| 156 | |
| 157 | The tool interacts minimally with the server upon which it runs. It assumes |
| 158 | that you'll run it on the same server you're inspecting, and therefore it |
| 159 | @@ -2557,24 +2620,24 @@ |
| 160 | database and operating system times match. |
| 161 | |
| 162 | # Processlist ################################################ |
| 163 | - |
| 164 | + |
| 165 | Command COUNT(*) Working SUM(Time) MAX(Time) |
| 166 | ------------------------------ -------- ------- --------- --------- |
| 167 | Binlog Dump 1 1 150000 150000 |
| 168 | Query 1 1 0 0 |
| 169 | - |
| 170 | + |
| 171 | User COUNT(*) Working SUM(Time) MAX(Time) |
| 172 | ------------------------------ -------- ------- --------- --------- |
| 173 | msandbox 2 2 150000 150000 |
| 174 | - |
| 175 | + |
| 176 | Host COUNT(*) Working SUM(Time) MAX(Time) |
| 177 | ------------------------------ -------- ------- --------- --------- |
| 178 | localhost 2 2 150000 150000 |
| 179 | - |
| 180 | + |
| 181 | db COUNT(*) Working SUM(Time) MAX(Time) |
| 182 | ------------------------------ -------- ------- --------- --------- |
| 183 | NULL 2 2 150000 150000 |
| 184 | - |
| 185 | + |
| 186 | State COUNT(*) Working SUM(Time) MAX(Time) |
| 187 | ------------------------------ -------- ------- --------- --------- |
| 188 | Master has sent all binlog to 1 1 150000 150000 |
| 189 | @@ -2667,22 +2730,22 @@ |
| 190 | Would you like to mysqldump -d the schema and analyze it? y/n y |
| 191 | There are 4 databases. Would you like to dump all, or just one? |
| 192 | Type the name of the database, or press Enter to dump all of them. |
| 193 | - |
| 194 | + |
| 195 | Database Tables Views SPs Trigs Funcs FKs Partn |
| 196 | mysql 24 |
| 197 | performance_schema 17 |
| 198 | sakila 16 7 3 6 3 22 |
| 199 | - |
| 200 | + |
| 201 | Database MyISAM CSV PERFORMANCE_SCHEMA InnoDB |
| 202 | mysql 22 2 |
| 203 | performance_schema 17 |
| 204 | sakila 8 15 |
| 205 | - |
| 206 | + |
| 207 | Database BTREE FULLTEXT |
| 208 | mysql 31 |
| 209 | performance_schema |
| 210 | sakila 63 1 |
| 211 | - |
| 212 | + |
| 213 | c t s e l d i t m v s |
| 214 | h i e n o a n i e a m |
| 215 | a m t u n t t n d r a |
| 216 | @@ -2889,36 +2952,73 @@ |
| 217 | Read this comma-separated list of config files. If specified, this must be the |
| 218 | first option on the command line. |
| 219 | |
| 220 | +=item --databases |
| 221 | + |
| 222 | +type: string |
| 223 | + |
| 224 | +Names of databases to summarize. If you want all of them, you can use the value |
| 225 | +C<--all-databases>; you can also pass in a comma-separated list of database |
| 226 | +names. If not provided, the program will ask you for manual input. |
| 227 | + |
| 228 | +=item --defaults-file |
| 229 | + |
| 230 | +short form: -F; type: string |
| 231 | + |
| 232 | +Only read mysql options from the given file. You must give an absolute |
| 233 | +pathname. |
| 234 | + |
| 235 | =item --help |
| 236 | |
| 237 | Print help and exit. |
| 238 | |
| 239 | +=item --host |
| 240 | + |
| 241 | +short form: -h; type: string |
| 242 | + |
| 243 | +Host to connect to. |
| 244 | + |
| 245 | +=item --password |
| 246 | + |
| 247 | +short form: -p; type: string |
| 248 | + |
| 249 | +Password to use when connecting. |
| 250 | + |
| 251 | +=item --port |
| 252 | + |
| 253 | +short form: -P; type: int |
| 254 | + |
| 255 | +Port number to use for connection. |
| 256 | + |
| 257 | +=item --read-samples |
| 258 | + |
| 259 | +type: string |
| 260 | + |
| 261 | +Create a report from the files found in this directory. |
| 262 | + |
| 263 | =item --save-samples |
| 264 | |
| 265 | type: string |
| 266 | |
| 267 | Save the data files used to generate the summary in this directory. |
| 268 | |
| 269 | -=item --read-samples |
| 270 | - |
| 271 | -type: string |
| 272 | - |
| 273 | -Create a report from the files found in this directory. |
| 274 | - |
| 275 | -=item --databases |
| 276 | - |
| 277 | -type: string |
| 278 | - |
| 279 | -Names of databases to summarize. If you want all of them, you can use the value |
| 280 | -C<--all-databases>; you can also pass in a comma-separated list of database |
| 281 | -names. If not provided, the program will ask you for manual input. |
| 282 | - |
| 283 | =item --sleep |
| 284 | |
| 285 | type: int; default: 10 |
| 286 | |
| 287 | Seconds to sleep when gathering status counters. |
| 288 | |
| 289 | +=item --socket |
| 290 | + |
| 291 | +short form: -S; type: string |
| 292 | + |
| 293 | +Socket file to use for connection. |
| 294 | + |
| 295 | +=item --user |
| 296 | + |
| 297 | +short form: -u; type: string |
| 298 | + |
| 299 | +User for login if not current user. |
| 300 | + |
| 301 | =item --version |
| 302 | |
| 303 | Print tool's version and exit. |
| 304 | |
| 305 | === modified file 'bin/pt-stalk' |
| 306 | --- bin/pt-stalk 2013-03-09 16:57:54 +0000 |
| 307 | +++ bin/pt-stalk 2013-03-09 18:49:22 +0000 |
| 308 | @@ -399,14 +399,14 @@ |
| 309 | |
| 310 | if [ "$next_opt_is_val" ]; then |
| 311 | next_opt_is_val="" |
| 312 | - if [ $# -eq 0 ] || [ $(expr "$opt" : "-") -eq 1 ]; then |
| 313 | + if [ $# -eq 0 ] || [ $(expr "$opt" : "\-") -eq 1 ]; then |
| 314 | option_error "$real_opt requires a $required_arg argument" |
| 315 | continue |
| 316 | fi |
| 317 | val="$opt" |
| 318 | opt_is_ok=1 |
| 319 | else |
| 320 | - if [ $(expr "$opt" : "-") -eq 0 ]; then |
| 321 | + if [ $(expr "$opt" : "\-") -eq 0 ]; then |
| 322 | if [ -z "$ARGV" ]; then |
| 323 | ARGV="$opt" |
| 324 | else |
| 325 | @@ -503,6 +503,61 @@ |
| 326 | # ########################################################################### |
| 327 | |
| 328 | # ########################################################################### |
| 329 | +# mysql_options package |
| 330 | +# This package is a copy without comments from the original. The original |
| 331 | +# with comments and its test file can be found in the Bazaar repository at, |
| 332 | +# lib/bash/mysql_options.sh |
| 333 | +# t/lib/bash/mysql_options.sh |
| 334 | +# See https://launchpad.net/percona-toolkit for more information. |
| 335 | +# ########################################################################### |
| 336 | + |
| 337 | + |
| 338 | +set -u |
| 339 | + |
| 340 | +mysql_options() { |
| 341 | + local MYSQL_ARGS="" |
| 342 | + if [ -n "$OPT_DEFAULTS_FILE" ]; then |
| 343 | + MYSQL_ARGS="--defaults-file=$OPT_DEFAULTS_FILE" |
| 344 | + fi |
| 345 | + if [ -n "$OPT_PORT" ]; then |
| 346 | + MYSQL_ARGS="$MYSQL_ARGS --port=$OPT_PORT" |
| 347 | + fi |
| 348 | + if [ -n "$OPT_SOCKET" ]; then |
| 349 | + MYSQL_ARGS="$MYSQL_ARGS --socket=$OPT_SOCKET" |
| 350 | + fi |
| 351 | + if [ -n "$OPT_HOST" ]; then |
| 352 | + MYSQL_ARGS="$MYSQL_ARGS --host=$OPT_HOST" |
| 353 | + fi |
| 354 | + if [ -n "$OPT_USER" ]; then |
| 355 | + MYSQL_ARGS="$MYSQL_ARGS --user=$OPT_USER" |
| 356 | + fi |
| 357 | + if [ -n "$OPT_PASSWORD" ]; then |
| 358 | + MYSQL_ARGS="$MYSQL_ARGS --password=$OPT_PASSWORD" |
| 359 | + fi |
| 360 | + |
| 361 | + echo $MYSQL_ARGS |
| 362 | +} |
| 363 | + |
| 364 | +arrange_mysql_options() { |
| 365 | + local opts="$1" |
| 366 | + |
| 367 | + local rearranged="" |
| 368 | + for opt in $opts; do |
| 369 | + if [ "$(echo $opt | awk -F= '{print $1}')" = "--defaults-file" ]; then |
| 370 | + rearranged="$opt $rearranged" |
| 371 | + else |
| 372 | + rearranged="$rearranged $opt" |
| 373 | + fi |
| 374 | + done |
| 375 | + |
| 376 | + echo "$rearranged" |
| 377 | +} |
| 378 | + |
| 379 | +# ########################################################################### |
| 380 | +# End mysql_options package |
| 381 | +# ########################################################################### |
| 382 | + |
| 383 | +# ########################################################################### |
| 384 | # tmpdir package |
| 385 | # This package is a copy without comments from the original. The original |
| 386 | # with comments and its test file can be found in the Bazaar repository at, |
| 387 | @@ -1370,6 +1425,9 @@ |
| 388 | exit 0 |
| 389 | fi |
| 390 | |
| 391 | + MYSQL_ARGS="$(mysql_options)" |
| 392 | + EXT_ARGV="$(arrange_mysql_options "$EXT_ARGV $MYSQL_ARGS")" |
| 393 | + |
| 394 | # Check that mysql and mysqladmin are in PATH. If not, we're |
| 395 | # already dead in the water, so don't bother with cmd line opts, |
| 396 | # just error and exit. |
| 397 | @@ -1439,13 +1497,23 @@ |
| 398 | |
| 399 | =head1 SYNOPSIS |
| 400 | |
| 401 | -Usage: pt-stalk [OPTIONS] [-- MYSQL OPTIONS] |
| 402 | +Usage: pt-stalk [OPTIONS] |
| 403 | |
| 404 | +<<<<<<< TREE |
| 405 | pt-stalk waits for a trigger condition to occur, then collects data |
| 406 | to help diagnose problems. The tool is designed to run as a daemon with root |
| 407 | +======= |
| 408 | +pt-stalk watches for a trigger condition to become true, and then collects data |
| 409 | +to help in diagnosing problems. It is designed to run as a daemon with root |
| 410 | +>>>>>>> MERGE-SOURCE |
| 411 | privileges, so that you can diagnose intermittent problems that you cannot |
| 412 | +<<<<<<< TREE |
| 413 | observe directly. You can also use it to execute a custom command, or to |
| 414 | collect data on demand without waiting for the trigger to occur. |
| 415 | +======= |
| 416 | +observe directly. You can also use it to execute a custom command, or to gather |
| 417 | +the data on demand without waiting for the trigger to happen. |
| 418 | +>>>>>>> MERGE-SOURCE |
| 419 | |
| 420 | =head1 RISKS |
| 421 | |
| 422 | @@ -1633,6 +1701,13 @@ |
| 423 | Daemonize the tool. This causes the tool to fork into the background and log |
| 424 | its output as specified in --log. |
| 425 | |
| 426 | +=item --defaults-file |
| 427 | + |
| 428 | +short form: -F; type: string |
| 429 | + |
| 430 | +Only read mysql options from the given file. You must give an absolute |
| 431 | +pathname. |
| 432 | + |
| 433 | =item --dest |
| 434 | |
| 435 | type: string; default: /var/lib/pt-stalk |
| 436 | @@ -1730,6 +1805,12 @@ |
| 437 | |
| 438 | Print help and exit. |
| 439 | |
| 440 | +=item --host |
| 441 | + |
| 442 | +short form: -h; type: string |
| 443 | + |
| 444 | +Host to connect to. |
| 445 | + |
| 446 | =item --interval |
| 447 | |
| 448 | type: int; default: 1 |
| 449 | @@ -1765,6 +1846,12 @@ |
| 450 | |
| 451 | Send an email to these addresses for every L<"--collect">. |
| 452 | |
| 453 | +=item --password |
| 454 | + |
| 455 | +short form: -p; type: string |
| 456 | + |
| 457 | +Password to use when connecting. |
| 458 | + |
| 459 | =item --pid |
| 460 | |
| 461 | type: string; default: /var/run/pt-stalk.pid |
| 462 | @@ -1839,6 +1926,12 @@ |
| 463 | to C<1>. In this case, the global variable C<EXIT_REASON> should also |
| 464 | be set to indicate why the tool was stopped. |
| 465 | |
| 466 | +=item --port |
| 467 | + |
| 468 | +short form: -P; type: int |
| 469 | + |
| 470 | +Port number to use for connection. |
| 471 | + |
| 472 | =item --prefix |
| 473 | |
| 474 | type: string |
| 475 | @@ -1886,6 +1979,12 @@ |
| 476 | It also prevents filling up the disk or gathering too much data to analyze |
| 477 | reasonably. |
| 478 | |
| 479 | +=item --socket |
| 480 | + |
| 481 | +short form: -S; type: string |
| 482 | + |
| 483 | +Socket file to use for connection. |
| 484 | + |
| 485 | =item --stalk |
| 486 | |
| 487 | default: yes; negatable: yes |
| 488 | @@ -1915,6 +2014,12 @@ |
| 489 | |
| 490 | See also L<"--function">. |
| 491 | |
| 492 | +=item --user |
| 493 | + |
| 494 | +short form: -u; type: string |
| 495 | + |
| 496 | +User for login if not current user. |
| 497 | + |
| 498 | =item --variable |
| 499 | |
| 500 | type: string; default: Threads_running |
| 501 | |
| 502 | === modified file 'bin/pt-summary' |
| 503 | --- bin/pt-summary 2013-03-09 16:57:54 +0000 |
| 504 | +++ bin/pt-summary 2013-03-09 18:49:22 +0000 |
| 505 | @@ -354,14 +354,14 @@ |
| 506 | |
| 507 | if [ "$next_opt_is_val" ]; then |
| 508 | next_opt_is_val="" |
| 509 | - if [ $# -eq 0 ] || [ $(expr "$opt" : "-") -eq 1 ]; then |
| 510 | + if [ $# -eq 0 ] || [ $(expr "$opt" : "\-") -eq 1 ]; then |
| 511 | option_error "$real_opt requires a $required_arg argument" |
| 512 | continue |
| 513 | fi |
| 514 | val="$opt" |
| 515 | opt_is_ok=1 |
| 516 | else |
| 517 | - if [ $(expr "$opt" : "-") -eq 0 ]; then |
| 518 | + if [ $(expr "$opt" : "\-") -eq 0 ]; then |
| 519 | if [ -z "$ARGV" ]; then |
| 520 | ARGV="$opt" |
| 521 | else |
| 522 | |
| 523 | === modified file 'lib/bash/collect_mysql_info.sh' |
| 524 | --- lib/bash/collect_mysql_info.sh 2012-11-27 21:28:07 +0000 |
| 525 | +++ lib/bash/collect_mysql_info.sh 2013-03-09 18:49:22 +0000 |
| 526 | @@ -43,7 +43,6 @@ |
| 527 | echo "internal::oom_of_$pid $oom" >> "$variables_file" |
| 528 | done |
| 529 | |
| 530 | - pids="$pids" |
| 531 | pids="$(echo $pids | sed -e 's/ /,/g')" |
| 532 | ps ww -p "$pids" 2>/dev/null |
| 533 | else |
| 534 | @@ -201,8 +200,13 @@ |
| 535 | collect_mysqld_executables () { |
| 536 | local mysqld_instances="$1" |
| 537 | |
| 538 | + local ps_opt="cmd=" |
| 539 | + if [ "$(uname -s)" = "Darwin" ]; then |
| 540 | + ps_opt="command=" |
| 541 | + fi |
| 542 | + |
| 543 | for pid in $( grep '/mysqld' "$mysqld_instances" | awk '/^.*[0-9]/{print $1}' ); do |
| 544 | - ps -o cmd -p $pid | sed -e 's/^\(.*mysqld\) .*/\1/' | grep -v '^CMD$' |
| 545 | + ps -o $ps_opt -p $pid | sed -e 's/^\(.*mysqld\) .*/\1/' |
| 546 | done | sort -u |
| 547 | } |
| 548 | |
| 549 | |
| 550 | === added file 'lib/bash/mysql_options.sh' |
| 551 | --- lib/bash/mysql_options.sh 1970-01-01 00:00:00 +0000 |
| 552 | +++ lib/bash/mysql_options.sh 2013-03-09 18:49:22 +0000 |
| 553 | @@ -0,0 +1,68 @@ |
| 554 | +# This program is copyright 2011 Percona Inc. |
| 555 | +# Feedback and improvements are welcome. |
| 556 | +# |
| 557 | +# THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
| 558 | +# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
| 559 | +# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 560 | +# |
| 561 | +# This program is free software; you can redistribute it and/or modify it under |
| 562 | +# the terms of the GNU General Public License as published by the Free Software |
| 563 | +# Foundation, version 2; OR the Perl Artistic License. On UNIX and similar |
| 564 | +# systems, you can issue `man perlgpl' or `man perlartistic' to read these |
| 565 | +# licenses. |
| 566 | +# |
| 567 | +# You should have received a copy of the GNU General Public License along with |
| 568 | +# this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
| 569 | +# Place, Suite 330, Boston, MA 02111-1307 USA. |
| 570 | +# ########################################################################### |
| 571 | +# mysql_options package |
| 572 | +# ########################################################################### |
| 573 | + |
| 574 | +# Package: mysql_options |
| 575 | +# Handle --defaults-file & related options |
| 576 | + |
| 577 | +set -u |
| 578 | + |
| 579 | +mysql_options() { |
| 580 | + local MYSQL_ARGS="" |
| 581 | + if [ -n "$OPT_DEFAULTS_FILE" ]; then |
| 582 | + MYSQL_ARGS="--defaults-file=$OPT_DEFAULTS_FILE" |
| 583 | + fi |
| 584 | + if [ -n "$OPT_PORT" ]; then |
| 585 | + MYSQL_ARGS="$MYSQL_ARGS --port=$OPT_PORT" |
| 586 | + fi |
| 587 | + if [ -n "$OPT_SOCKET" ]; then |
| 588 | + MYSQL_ARGS="$MYSQL_ARGS --socket=$OPT_SOCKET" |
| 589 | + fi |
| 590 | + if [ -n "$OPT_HOST" ]; then |
| 591 | + MYSQL_ARGS="$MYSQL_ARGS --host=$OPT_HOST" |
| 592 | + fi |
| 593 | + if [ -n "$OPT_USER" ]; then |
| 594 | + MYSQL_ARGS="$MYSQL_ARGS --user=$OPT_USER" |
| 595 | + fi |
| 596 | + if [ -n "$OPT_PASSWORD" ]; then |
| 597 | + MYSQL_ARGS="$MYSQL_ARGS --password=$OPT_PASSWORD" |
| 598 | + fi |
| 599 | + |
| 600 | + echo $MYSQL_ARGS |
| 601 | +} |
| 602 | + |
| 603 | +# This basically makes sure that --defaults-file comes first |
| 604 | +arrange_mysql_options() { |
| 605 | + local opts="$1" |
| 606 | + |
| 607 | + local rearranged="" |
| 608 | + for opt in $opts; do |
| 609 | + if [ "$(echo $opt | awk -F= '{print $1}')" = "--defaults-file" ]; then |
| 610 | + rearranged="$opt $rearranged" |
| 611 | + else |
| 612 | + rearranged="$rearranged $opt" |
| 613 | + fi |
| 614 | + done |
| 615 | + |
| 616 | + echo "$rearranged" |
| 617 | +} |
| 618 | + |
| 619 | +# ########################################################################### |
| 620 | +# End mysql_options package |
| 621 | +# ########################################################################### |
| 622 | |
| 623 | === modified file 'lib/bash/parse_options.sh' |
| 624 | --- lib/bash/parse_options.sh 2012-11-27 21:05:53 +0000 |
| 625 | +++ lib/bash/parse_options.sh 2013-03-09 18:49:22 +0000 |
| 626 | @@ -398,7 +398,7 @@ |
| 627 | |
| 628 | if [ "$next_opt_is_val" ]; then |
| 629 | next_opt_is_val="" |
| 630 | - if [ $# -eq 0 ] || [ $(expr "$opt" : "-") -eq 1 ]; then |
| 631 | + if [ $# -eq 0 ] || [ $(expr "$opt" : "\-") -eq 1 ]; then |
| 632 | option_error "$real_opt requires a $required_arg argument" |
| 633 | continue |
| 634 | fi |
| 635 | @@ -406,7 +406,7 @@ |
| 636 | opt_is_ok=1 |
| 637 | else |
| 638 | # If option does not begin with a hyphen (-), it's a filename, etc. |
| 639 | - if [ $(expr "$opt" : "-") -eq 0 ]; then |
| 640 | + if [ $(expr "$opt" : "\-") -eq 0 ]; then |
| 641 | if [ -z "$ARGV" ]; then |
| 642 | ARGV="$opt" |
| 643 | else |
| 644 | |
| 645 | === modified file 'lib/bash/report_mysql_info.sh' |
| 646 | --- lib/bash/report_mysql_info.sh 2012-12-06 00:10:22 +0000 |
| 647 | +++ lib/bash/report_mysql_info.sh 2013-03-09 18:49:22 +0000 |
| 648 | @@ -1489,6 +1489,7 @@ |
| 649 | # ######################################################################## |
| 650 | section "Configuration File" |
| 651 | local cnf_file="$(get_var "pt-summary-internal-Config_File_path" "$dir/mysql-variables")" |
| 652 | + |
| 653 | if [ -n "${cnf_file}" ]; then |
| 654 | name_val "Config File" "${cnf_file}" |
| 655 | pretty_print_cnf_file "$dir/mysql-config-file" |
| 656 | |
| 657 | === added file 't/lib/bash/mysql_options.sh' |
| 658 | --- t/lib/bash/mysql_options.sh 1970-01-01 00:00:00 +0000 |
| 659 | +++ t/lib/bash/mysql_options.sh 2013-03-09 18:49:22 +0000 |
| 660 | @@ -0,0 +1,30 @@ |
| 661 | +#!/usr/bin/env bash |
| 662 | + |
| 663 | +plan 3 |
| 664 | + |
| 665 | +TMPFILE="$TEST_PT_TMPDIR/parse-opts-output" |
| 666 | +TOOL="pt-mysql-summary" |
| 667 | +PT_TMPDIR="$TEST_PT_TMPDIR" |
| 668 | + |
| 669 | +source "$LIB_DIR/log_warn_die.sh" |
| 670 | +source "$LIB_DIR/parse_options.sh" |
| 671 | +source "$LIB_DIR/mysql_options.sh" |
| 672 | + |
| 673 | +cnf="/tmp/12345/my.sandbox.cnf" |
| 674 | + |
| 675 | +parse_options "$PERCONA_TOOLKIT_BRANCH/bin/pt-mysql-summary" --defaults-file $cnf |
| 676 | +is "$OPT_DEFAULTS_FILE" "$cnf" "--defaults-file works" |
| 677 | + |
| 678 | +# ############################################################################ |
| 679 | +# Short forms work |
| 680 | +# ############################################################################ |
| 681 | + |
| 682 | +parse_options "$PERCONA_TOOLKIT_BRANCH/bin/pt-mysql-summary" -F $cnf |
| 683 | +is "$OPT_DEFAULTS_FILE" "$cnf" "-F works" |
| 684 | + |
| 685 | +parse_options "$PERCONA_TOOLKIT_BRANCH/bin/pt-mysql-summary" -u msandbox |
| 686 | +is "$OPT_USER" "msandbox" "-u works" |
| 687 | + |
| 688 | +# ############################################################################ |
| 689 | +# Done |
| 690 | +# ############################################################################ |
| 691 | |
| 692 | === added symlink 't/lib/bash/mysql_options.t' |
| 693 | === target is u'../../../util/test-bash-functions' |
| 694 | === modified file 't/pt-stalk/pt-stalk.t' |
| 695 | --- t/pt-stalk/pt-stalk.t 2013-03-04 22:57:52 +0000 |
| 696 | +++ t/pt-stalk/pt-stalk.t 2013-03-09 18:49:22 +0000 |
| 697 | @@ -144,7 +144,7 @@ |
| 698 | |
| 699 | cleanup(); |
| 700 | |
| 701 | -$retval = system("$trunk/bin/pt-stalk --daemonize --pid $pid_file --log $log_file --dest $dest --verbose 3 -- --defaults-file=$cnf"); |
| 702 | +$retval = system("$trunk/bin/pt-stalk --daemonize --pid $pid_file --log $log_file --variable Threads_running --dest $dest --verbose 3 -- --defaults-file=$cnf"); |
| 703 | |
| 704 | PerconaTest::wait_for_files($pid_file, $log_file); |
| 705 | PerconaTest::wait_for_sh("grep -q 'Check results' $log_file >/dev/null"); |
| 706 | @@ -155,7 +155,7 @@ |
| 707 | $output, |
| 708 | qr/Check results: Threads_running=\d+, matched=no, cycles_true=0/, |
| 709 | "Matching results logged with --verbose 3" |
| 710 | -) or diag(`cat $log_file 2>/dev/null`, `cat $dest/*-output 2>/dev/null`); |
| 711 | +) or diag(`cat $dest/*-output 2>/dev/null`); |
| 712 | |
| 713 | # ############################################################################# |
| 714 | # --verbose 1 (just errors and warnings) |

https:/ /refute. testnoir. com/percona- toolkit/ jobs/percona- toolkit- full-branch- test/19/ results/ errors