~percona-toolkit-dev/percona-toolkit/release-2.2.2

« back to all changes in this revision

Viewing changes to bin/pt-pmp

Merge version-in-all-bash-tools-bug-821502.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
TOOL="pt-pmp"
8
8
 
9
9
# ###########################################################################
 
10
# log_warn_die package
 
11
# This package is a copy without comments from the original.  The original
 
12
# with comments and its test file can be found in the Bazaar repository at,
 
13
#   lib/bash/log_warn_die.sh
 
14
#   t/lib/bash/log_warn_die.sh
 
15
# See https://launchpad.net/percona-toolkit for more information.
 
16
# ###########################################################################
 
17
 
 
18
 
 
19
set -u
 
20
 
 
21
PTFUNCNAME=""
 
22
PTDEBUG="${PTDEBUG:-""}"
 
23
EXIT_STATUS=0
 
24
 
 
25
ts() {
 
26
   TS=$(date +%F-%T | tr ':-' '_')
 
27
   echo "$TS $*"
 
28
}
 
29
 
 
30
info() {
 
31
   [ ${OPT_VERBOSE:-3} -ge 3 ] && ts "$*"
 
32
}
 
33
 
 
34
log() {
 
35
   [ ${OPT_VERBOSE:-3} -ge 2 ] && ts "$*"
 
36
}
 
37
 
 
38
warn() {
 
39
   [ ${OPT_VERBOSE:-3} -ge 1 ] && ts "$*" >&2
 
40
   EXIT_STATUS=1
 
41
}
 
42
 
 
43
die() {
 
44
   ts "$*" >&2
 
45
   EXIT_STATUS=1
 
46
   exit 1
 
47
}
 
48
 
 
49
_d () {
 
50
   [ "$PTDEBUG" ] && echo "# $PTFUNCNAME: $(ts "$*")" >&2
 
51
}
 
52
 
 
53
# ###########################################################################
 
54
# End log_warn_die package
 
55
# ###########################################################################
 
56
 
 
57
# ###########################################################################
10
58
# tmpdir package
11
59
# This package is a copy without comments from the original.  The original
12
60
# with comments and its test file can be found in the Bazaar repository at,
47
95
# End tmpdir package
48
96
# ###########################################################################
49
97
 
 
98
# ###########################################################################
 
99
# parse_options package
 
100
# This package is a copy without comments from the original.  The original
 
101
# with comments and its test file can be found in the Bazaar repository at,
 
102
#   lib/bash/parse_options.sh
 
103
#   t/lib/bash/parse_options.sh
 
104
# See https://launchpad.net/percona-toolkit for more information.
 
105
# ###########################################################################
 
106
 
 
107
 
 
108
 
 
109
 
 
110
 
 
111
set -u
 
112
 
 
113
ARGV=""           # Non-option args (probably input files)
 
114
EXT_ARGV=""       # Everything after -- (args for an external command)
 
115
HAVE_EXT_ARGV=""  # Got --, everything else is put into EXT_ARGV
 
116
OPT_ERRS=0        # How many command line option errors
 
117
OPT_VERSION=""    # If --version was specified
 
118
OPT_HELP=""       # If --help was specified
 
119
PO_DIR=""         # Directory with program option spec files
 
120
 
 
121
usage() {
 
122
   local file="$1"
 
123
 
 
124
   local usage="$(grep '^Usage: ' "$file")"
 
125
   echo $usage
 
126
   echo
 
127
   echo "For more information, 'man $TOOL' or 'perldoc $file'."
 
128
}
 
129
 
 
130
usage_or_errors() {
 
131
   local file="$1"
 
132
 
 
133
   if [ "$OPT_VERSION" ]; then
 
134
      local version=$(grep '^pt-[^ ]\+ [0-9]' "$file")
 
135
      echo "$version"
 
136
      return 1
 
137
   fi
 
138
 
 
139
   if [ "$OPT_HELP" ]; then
 
140
      usage "$file"
 
141
      echo
 
142
      echo "Command line options:"
 
143
      echo
 
144
      perl -e '
 
145
         use strict;
 
146
         use warnings FATAL => qw(all);
 
147
         my $lcol = 20;         # Allow this much space for option names.
 
148
         my $rcol = 80 - $lcol; # The terminal is assumed to be 80 chars wide.
 
149
         my $name;
 
150
         while ( <> ) {
 
151
            my $line = $_;
 
152
            chomp $line;
 
153
            if ( $line =~ s/^long:/  --/ ) {
 
154
               $name = $line;
 
155
            }
 
156
            elsif ( $line =~ s/^desc:// ) {
 
157
               $line =~ s/ +$//mg;
 
158
               my @lines = grep { $_      }
 
159
                           $line =~ m/(.{0,$rcol})(?:\s+|\Z)/g;
 
160
               if ( length($name) >= $lcol ) {
 
161
                  print $name, "\n", (q{ } x $lcol);
 
162
               }
 
163
               else {
 
164
                  printf "%-${lcol}s", $name;
 
165
               }
 
166
               print join("\n" . (q{ } x $lcol), @lines);
 
167
               print "\n";
 
168
            }
 
169
         }
 
170
      ' "$PO_DIR"/*
 
171
      echo
 
172
      echo "Options and values after processing arguments:"
 
173
      echo
 
174
      (
 
175
         cd "$PO_DIR"
 
176
         for opt in *; do
 
177
            local varname="OPT_$(echo "$opt" | tr a-z- A-Z_)"
 
178
            eval local varvalue=\$$varname
 
179
            if ! grep -q "type:" "$PO_DIR/$opt" >/dev/null; then
 
180
               if [ "$varvalue" -a "$varvalue" = "yes" ];
 
181
                  then varvalue="TRUE"
 
182
               else
 
183
                  varvalue="FALSE"
 
184
               fi
 
185
            fi
 
186
            printf -- "  --%-30s %s" "$opt" "${varvalue:-(No value)}"
 
187
            echo
 
188
         done
 
189
      )
 
190
      return 1
 
191
   fi
 
192
 
 
193
   if [ $OPT_ERRS -gt 0 ]; then
 
194
      echo
 
195
      usage "$file"
 
196
      return 1
 
197
   fi
 
198
 
 
199
   return 0
 
200
}
 
201
 
 
202
option_error() {
 
203
   local err="$1"
 
204
   OPT_ERRS=$(($OPT_ERRS + 1))
 
205
   echo "$err" >&2
 
206
}
 
207
 
 
208
parse_options() {
 
209
   local file="$1"
 
210
   shift
 
211
 
 
212
   ARGV=""
 
213
   EXT_ARGV=""
 
214
   HAVE_EXT_ARGV=""
 
215
   OPT_ERRS=0
 
216
   OPT_VERSION=""
 
217
   OPT_HELP=""
 
218
   PO_DIR="$PT_TMPDIR/po"
 
219
 
 
220
   if [ ! -d "$PO_DIR" ]; then
 
221
      mkdir "$PO_DIR"
 
222
      if [ $? -ne 0 ]; then
 
223
         echo "Cannot mkdir $PO_DIR" >&2
 
224
         exit 1
 
225
      fi
 
226
   fi
 
227
 
 
228
   rm -rf "$PO_DIR"/*
 
229
   if [ $? -ne 0 ]; then
 
230
      echo "Cannot rm -rf $PO_DIR/*" >&2
 
231
      exit 1
 
232
   fi
 
233
 
 
234
   _parse_pod "$file"  # Parse POD into program option (po) spec files
 
235
   _eval_po            # Eval po into existence with default values
 
236
 
 
237
   if [ $# -ge 2 ] &&  [ "$1" = "--config" ]; then
 
238
      shift  # --config
 
239
      local user_config_files="$1"
 
240
      shift  # that ^
 
241
      local IFS=","
 
242
      for user_config_file in $user_config_files; do
 
243
         _parse_config_files "$user_config_file"
 
244
      done
 
245
   else
 
246
      _parse_config_files "/etc/percona-toolkit/percona-toolkit.conf" "/etc/percona-toolkit/$TOOL.conf" "$HOME/.percona-toolkit.conf" "$HOME/.$TOOL.conf"
 
247
   fi
 
248
 
 
249
   _parse_command_line "${@:-""}"
 
250
}
 
251
 
 
252
_parse_pod() {
 
253
   local file="$1"
 
254
 
 
255
   cat "$file" | PO_DIR="$PO_DIR" perl -ne '
 
256
      BEGIN { $/ = ""; }
 
257
      next unless $_ =~ m/^=head1 OPTIONS/;
 
258
      while ( defined(my $para = <>) ) {
 
259
         last if $para =~ m/^=head1/;
 
260
         chomp;
 
261
         if ( $para =~ m/^=item --(\S+)/ ) {
 
262
            my $opt  = $1;
 
263
            my $file = "$ENV{PO_DIR}/$opt";
 
264
            open my $opt_fh, ">", $file or die "Cannot open $file: $!";
 
265
            print $opt_fh "long:$opt\n";
 
266
            $para = <>;
 
267
            chomp;
 
268
            if ( $para =~ m/^[a-z ]+:/ ) {
 
269
               map {
 
270
                  chomp;
 
271
                  my ($attrib, $val) = split(/: /, $_);
 
272
                  print $opt_fh "$attrib:$val\n";
 
273
               } split(/; /, $para);
 
274
               $para = <>;
 
275
               chomp;
 
276
            }
 
277
            my ($desc) = $para =~ m/^([^?.]+)/;
 
278
            print $opt_fh "desc:$desc.\n";
 
279
            close $opt_fh;
 
280
         }
 
281
      }
 
282
      last;
 
283
   '
 
284
}
 
285
 
 
286
_eval_po() {
 
287
   local IFS=":"
 
288
   for opt_spec in "$PO_DIR"/*; do
 
289
      local opt=""
 
290
      local default_val=""
 
291
      local neg=0
 
292
      local size=0
 
293
      while read key val; do
 
294
         case "$key" in
 
295
            long)
 
296
               opt=$(echo $val | sed 's/-/_/g' | tr '[:lower:]' '[:upper:]')
 
297
               ;;
 
298
            default)
 
299
               default_val="$val"
 
300
               ;;
 
301
            "short form")
 
302
               ;;
 
303
            type)
 
304
               [ "$val" = "size" ] && size=1
 
305
               ;;
 
306
            desc)
 
307
               ;;
 
308
            negatable)
 
309
               if [ "$val" = "yes" ]; then
 
310
                  neg=1
 
311
               fi
 
312
               ;;
 
313
            *)
 
314
               echo "Invalid attribute in $opt_spec: $line" >&2
 
315
               exit 1
 
316
         esac 
 
317
      done < "$opt_spec"
 
318
 
 
319
      if [ -z "$opt" ]; then
 
320
         echo "No long attribute in option spec $opt_spec" >&2
 
321
         exit 1
 
322
      fi
 
323
 
 
324
      if [ $neg -eq 1 ]; then
 
325
         if [ -z "$default_val" ] || [ "$default_val" != "yes" ]; then
 
326
            echo "Option $opt_spec is negatable but not default: yes" >&2
 
327
            exit 1
 
328
         fi
 
329
      fi
 
330
 
 
331
      if [ $size -eq 1 -a -n "$default_val" ]; then
 
332
         default_val=$(size_to_bytes $default_val)
 
333
      fi
 
334
 
 
335
      eval "OPT_${opt}"="$default_val"
 
336
   done
 
337
}
 
338
 
 
339
_parse_config_files() {
 
340
 
 
341
   for config_file in "${@:-""}"; do
 
342
      test -f "$config_file" || continue
 
343
 
 
344
      while read config_opt; do
 
345
 
 
346
         echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue
 
347
 
 
348
         config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]*#.*$//')"
 
349
 
 
350
         [ "$config_opt" = "" ] && continue
 
351
 
 
352
         if ! [ "$HAVE_EXT_ARGV" ]; then
 
353
            config_opt="--$config_opt"
 
354
         fi
 
355
 
 
356
         _parse_command_line "$config_opt"
 
357
 
 
358
      done < "$config_file"
 
359
 
 
360
      HAVE_EXT_ARGV=""  # reset for each file
 
361
 
 
362
   done
 
363
}
 
364
 
 
365
_parse_command_line() {
 
366
   local opt=""
 
367
   local val=""
 
368
   local next_opt_is_val=""
 
369
   local opt_is_ok=""
 
370
   local opt_is_negated=""
 
371
   local real_opt=""
 
372
   local required_arg=""
 
373
   local spec=""
 
374
 
 
375
   for opt in "${@:-""}"; do
 
376
      if [ "$opt" = "--" -o "$opt" = "----" ]; then
 
377
         HAVE_EXT_ARGV=1
 
378
         continue
 
379
      fi
 
380
      if [ "$HAVE_EXT_ARGV" ]; then
 
381
         if [ "$EXT_ARGV" ]; then
 
382
            EXT_ARGV="$EXT_ARGV $opt"
 
383
         else
 
384
            EXT_ARGV="$opt"
 
385
         fi
 
386
         continue
 
387
      fi
 
388
 
 
389
      if [ "$next_opt_is_val" ]; then
 
390
         next_opt_is_val=""
 
391
         if [ $# -eq 0 ] || [ $(expr "$opt" : "\-") -eq 1 ]; then
 
392
            option_error "$real_opt requires a $required_arg argument"
 
393
            continue
 
394
         fi
 
395
         val="$opt"
 
396
         opt_is_ok=1
 
397
      else
 
398
         if [ $(expr "$opt" : "\-") -eq 0 ]; then
 
399
            if [ -z "$ARGV" ]; then
 
400
               ARGV="$opt"
 
401
            else
 
402
               ARGV="$ARGV $opt"
 
403
            fi
 
404
            continue
 
405
         fi
 
406
 
 
407
         real_opt="$opt"
 
408
 
 
409
         if $(echo $opt | grep '^--no[^-]' >/dev/null); then
 
410
            local base_opt=$(echo $opt | sed 's/^--no//')
 
411
            if [ -f "$PT_TMPDIR/po/$base_opt" ]; then
 
412
               opt_is_negated=1
 
413
               opt="$base_opt"
 
414
            else
 
415
               opt_is_negated=""
 
416
               opt=$(echo $opt | sed 's/^-*//')
 
417
            fi
 
418
         else
 
419
            if $(echo $opt | grep '^--no-' >/dev/null); then
 
420
               opt_is_negated=1
 
421
               opt=$(echo $opt | sed 's/^--no-//')
 
422
            else
 
423
               opt_is_negated=""
 
424
               opt=$(echo $opt | sed 's/^-*//')
 
425
            fi
 
426
         fi
 
427
 
 
428
         if $(echo $opt | grep '^[a-z-][a-z-]*=' >/dev/null 2>&1); then
 
429
            val="$(echo $opt | awk -F= '{print $2}')"
 
430
            opt="$(echo $opt | awk -F= '{print $1}')"
 
431
         fi
 
432
 
 
433
         if [ -f "$PT_TMPDIR/po/$opt" ]; then
 
434
            spec="$PT_TMPDIR/po/$opt"
 
435
         else
 
436
            spec=$(grep "^short form:-$opt\$" "$PT_TMPDIR"/po/* | cut -d ':' -f 1)
 
437
            if [ -z "$spec"  ]; then
 
438
               option_error "Unknown option: $real_opt"
 
439
               continue
 
440
            fi
 
441
         fi
 
442
 
 
443
         required_arg=$(cat "$spec" | awk -F: '/^type:/{print $2}')
 
444
         if [ "$required_arg" ]; then
 
445
            if [ "$val" ]; then
 
446
               opt_is_ok=1
 
447
            else
 
448
               next_opt_is_val=1
 
449
            fi
 
450
         else
 
451
            if [ "$val" ]; then
 
452
               option_error "Option $real_opt does not take a value"
 
453
               continue
 
454
            fi 
 
455
            if [ "$opt_is_negated" ]; then
 
456
               val=""
 
457
            else
 
458
               val="yes"
 
459
            fi
 
460
            opt_is_ok=1
 
461
         fi
 
462
      fi
 
463
 
 
464
      if [ "$opt_is_ok" ]; then
 
465
         opt=$(cat "$spec" | grep '^long:' | cut -d':' -f2 | sed 's/-/_/g' | tr '[:lower:]' '[:upper:]')
 
466
 
 
467
         if grep "^type:size" "$spec" >/dev/null; then
 
468
            val=$(size_to_bytes $val)
 
469
         fi
 
470
 
 
471
         eval "OPT_$opt"="'$val'"
 
472
 
 
473
         opt=""
 
474
         val=""
 
475
         next_opt_is_val=""
 
476
         opt_is_ok=""
 
477
         opt_is_negated=""
 
478
         real_opt=""
 
479
         required_arg=""
 
480
         spec=""
 
481
      fi
 
482
   done
 
483
}
 
484
 
 
485
size_to_bytes() {
 
486
   local size="$1"
 
487
   echo $size | perl -ne '%f=(B=>1, K=>1_024, M=>1_048_576, G=>1_073_741_824, T=>1_099_511_627_776); m/^(\d+)([kMGT])?/i; print $1 * $f{uc($2 || "B")};'
 
488
}
 
489
 
 
490
# ###########################################################################
 
491
# End parse_options package
 
492
# ###########################################################################
 
493
 
 
494
# ###########################################################################
 
495
# alt_cmds package
 
496
# This package is a copy without comments from the original.  The original
 
497
# with comments and its test file can be found in the Bazaar repository at,
 
498
#   lib/bash/alt_cmds.sh
 
499
#   t/lib/bash/alt_cmds.sh
 
500
# See https://launchpad.net/percona-toolkit for more information.
 
501
# ###########################################################################
 
502
 
 
503
 
 
504
set -u
 
505
 
 
506
_seq() {
 
507
   local i="$1"
 
508
   awk "BEGIN { for(i=1; i<=$i; i++) print i; }"
 
509
}
 
510
 
 
511
_pidof() {
 
512
   local cmd="$1"
 
513
   if ! pidof "$cmd" 2>/dev/null; then
 
514
      ps -eo pid,ucomm | awk -v comm="$cmd" '$2 == comm { print $1 }'
 
515
   fi
 
516
}
 
517
 
 
518
_lsof() {
 
519
   local pid="$1"
 
520
   if ! lsof -p $pid 2>/dev/null; then
 
521
      /bin/ls -l /proc/$pid/fd 2>/dev/null
 
522
   fi
 
523
}
 
524
 
 
525
 
 
526
 
 
527
_which() {
 
528
   if [ -x /usr/bin/which ]; then
 
529
      /usr/bin/which "$1" 2>/dev/null | awk '{print $1}'
 
530
   elif which which 1>/dev/null 2>&1; then
 
531
      which "$1" 2>/dev/null | awk '{print $1}'
 
532
   else
 
533
      echo "$1"
 
534
   fi
 
535
}
 
536
 
 
537
# ###########################################################################
 
538
# End alt_cmds package
 
539
# ###########################################################################
 
540
 
50
541
set +u
51
542
 
52
 
usage() {
53
 
   if [ "${OPT_ERR}" ]; then
54
 
      echo "${OPT_ERR}" >&2
55
 
   fi
56
 
   echo "Usage: pt-pmp [OPTIONS] [FILES]" >&2
57
 
   echo "For more information, 'man pt-pmp' or 'perldoc $0'" >&2
58
 
   exit 1
59
 
}
60
 
 
61
543
# Actually does the aggregation.  The arguments are the max number of functions
62
544
# to aggregate, and the files to read.  If maxlen=0, it means infinity.  We have
63
545
# to pass the maxlen argument into this function to make maxlen testable.
153
635
 
154
636
# The main program to run.
155
637
main() {
156
 
 
157
 
   # Get command-line options
158
 
   for o; do
159
 
      case "${o}" in
160
 
         --)
161
 
            shift; break;
162
 
            ;;
163
 
         --help)
164
 
            usage;
165
 
            ;;
166
 
         -b)
167
 
            shift; OPT_b="${1}"; shift;
168
 
            ;;
169
 
         -i)
170
 
            shift; OPT_i="${1}"; shift;
171
 
            ;;
172
 
         -k)
173
 
            shift; OPT_k="${1}"; shift;
174
 
            ;;
175
 
         -l)
176
 
            shift; OPT_l="${1}"; shift;
177
 
            ;;
178
 
         -p)
179
 
            shift; OPT_p="${1}"; shift;
180
 
            ;;
181
 
         -s)
182
 
            shift; OPT_s="${1}"; shift;
183
 
            ;;
184
 
         -*)
185
 
            OPT_ERR="Unknown option ${o}."
186
 
            usage
187
 
            ;;
188
 
      esac
189
 
   done
190
 
   export OPT_i="${OPT_i:-1}";
191
 
   export OPT_k="${OPT_k:-}";
192
 
   export OPT_l="${OPT_l:-0}";
193
 
   export OPT_b="${OPT_b:-mysqld}";
194
 
   export OPT_p="${OPT_p:-}";
195
 
   export OPT_s="${OPT_s:-0}";
196
 
 
197
 
   if [ -z "${1}" ]; then
198
 
      # There's no file to analyze, so we'll make one.
199
 
      if [ -z "${OPT_p}" ]; then
200
 
         OPT_p=$(pidof -s "${OPT_b}" 2>/dev/null);
201
 
         if [ -z "${OPT_p}" ]; then
202
 
            OPT_p=$(pgrep -o -x "${OPT_b}" 2>/dev/null)
 
638
   local output_file="${OPT_SAVE_SAMPLES:-"$PT_TMPDIR/percona-toolkit"}"
 
639
 
 
640
   if [ -z "$ARGV" ]; then
 
641
      # There are no files to analyze, so we'll make one.
 
642
      if [ -z "$OPT_PID" ]; then
 
643
         OPT_PID=$(pidof -s "$OPT_BINARY" 2>/dev/null);
 
644
         if [ -z "$OPT_PID" ]; then
 
645
            OPT_PID=$(pgrep -o -x "$OPT_BINARY" 2>/dev/null)
203
646
         fi
204
 
         if [ -z "${OPT_p}" ]; then
205
 
            OPT_p=$(ps -eaf | grep "${OPT_b}" | grep -v grep | awk '{print $2}' | head -n1);
 
647
         if [ -z "$OPT_PID" ]; then
 
648
            OPT_PID=$(ps -eaf | grep "$OPT_BINARY" | grep -v grep | awk '{print $2}' | head -n1);
206
649
         fi
207
650
      fi
208
 
      date;
209
 
      for x in $(seq 1 $OPT_i); do
210
 
         gdb -ex "set pagination 0" -ex "thread apply all bt" -batch -p $OPT_p >> "${OPT_k:-$PT_TMPDIR/percona-toolkit}"
211
 
         date +'TS %N.%s %F %T' >> "${OPT_k:-$PT_TMPDIR/percona-toolkit}"
212
 
         sleep $OPT_s
 
651
      date
 
652
      for x in $(_seq $OPT_ITERATIONS); do
 
653
         gdb -ex "set pagination 0"    \
 
654
             -ex "thread apply all bt" \
 
655
             -batch                    \
 
656
             -p $OPT_PID               \
 
657
             >> "$output_file"
 
658
         date +'TS %N.%s %F %T' >> "$output_file"
 
659
         sleep $OPT_INTERVAL
213
660
      done
214
661
   fi
215
662
 
216
 
   if [ $# -eq 0 ]; then
217
 
      aggregate_stacktrace "${OPT_l}" "${OPT_k:-$PT_TMPDIR/percona-toolkit}"
 
663
   if [ -z "$ARGV" ]; then
 
664
      aggregate_stacktrace "$OPT_LINES" "$output_file"
218
665
   else
219
 
      aggregate_stacktrace "${OPT_l}" "$@"
 
666
      aggregate_stacktrace "$OPT_LINES" $ARGV
220
667
   fi
221
668
}
222
669
 
224
671
# possible to include without executing, and thus test.
225
672
if    [ "${0##*/}" = "$TOOL" ] \
226
673
   || [ "${0##*/}" = "bash" -a "${_:-""}" = "$0" ]; then
 
674
 
227
675
   mk_tmpdir
228
 
   main "$@"
 
676
 
 
677
   parse_options "$0" "${@:-""}"
 
678
   if [ -z "$OPT_HELP" -a -z "$OPT_VERSION" ]; then
 
679
      # Validate options
 
680
      :
 
681
   fi
 
682
   usage_or_errors "$0"
 
683
   po_status=$?
 
684
   if [ $po_status -ne 0 ]; then
 
685
      [ $OPT_ERRS -gt 0 ] && exit 1
 
686
      exit 0
 
687
   fi
 
688
 
 
689
   main $ARGV
 
690
 
229
691
   rm_tmpdir
230
692
fi
231
693
 
289
751
 
290
752
=head1 OPTIONS
291
753
 
292
 
Options must precede files on the command line.
293
 
 
294
754
=over
295
755
 
296
 
=item -b BINARY
297
 
 
298
 
Which binary to trace (default mysqld)
299
 
 
300
 
=item -i ITERATIONS
301
 
 
302
 
How many traces to gather and aggregate (default 1)
303
 
 
304
 
=item -k KEEPFILE
305
 
 
306
 
Keep the raw traces in this file after aggregation
307
 
 
308
 
=item -l NUMBER
309
 
 
310
 
Aggregate only first NUMBER functions; 0=infinity (default 0)
311
 
 
312
 
=item -p PID
313
 
 
314
 
Process ID of the process to trace; overrides -b
315
 
 
316
 
=item -s SLEEPTIME
317
 
 
318
 
Number of seconds to sleep between iterations (default 0)
 
756
=item --binary
 
757
 
 
758
short form: -b; type: string; default: mysqld
 
759
 
 
760
Which binary to trace.
 
761
 
 
762
=item --help
 
763
 
 
764
Show help and exit.
 
765
 
 
766
=item --interval
 
767
 
 
768
short form: -s; type: int; default: 0
 
769
 
 
770
Number of seconds to sleep between L<"--iterations">.
 
771
 
 
772
=item --iterations
 
773
 
 
774
short form: -i; type: int; default: 1
 
775
 
 
776
How many traces to gather and aggregate.
 
777
 
 
778
=item --lines
 
779
 
 
780
short form: -l; type: int; default: 0
 
781
 
 
782
Aggregate only first specified number of many functions; 0=infinity.
 
783
 
 
784
=item --pid
 
785
 
 
786
short form: -p; type: int
 
787
 
 
788
Process ID of the process to trace; overrides L<"--binary">.
 
789
 
 
790
=item --save-samples
 
791
 
 
792
short form: -k; type: string
 
793
 
 
794
Keep the raw traces in this file after aggregation.
 
795
 
 
796
=item --version
 
797
 
 
798
Show version and exit.
319
799
 
320
800
=back
321
801