Commit 3ce3295e authored by kent@mysql.com's avatar kent@mysql.com

mysqldumpslow.sh:

  bug#4914 added --help and usage information
parent 61214228
...@@ -17,8 +17,9 @@ my %opt = ( ...@@ -17,8 +17,9 @@ my %opt = (
); );
GetOptions(\%opt, GetOptions(\%opt,
'v+', # verbose 'verbose|v+',# verbose
'd+', # debug 'help+', # write usage info
'debug|d+', # debug
's=s', # what to sort by (t, at, l, al, r, ar etc) 's=s', # what to sort by (t, at, l, al, r, ar etc)
'r!', # reverse the sort order (largest last instead of first) 'r!', # reverse the sort order (largest last instead of first)
't=i', # just show the top n queries 't=i', # just show the top n queries
...@@ -28,8 +29,9 @@ GetOptions(\%opt, ...@@ -28,8 +29,9 @@ GetOptions(\%opt,
'h=s', # hostname of db server for *-slow.log filename (can be wildcard) 'h=s', # hostname of db server for *-slow.log filename (can be wildcard)
'i=s', # name of server instance (if using mysql.server startup script) 'i=s', # name of server instance (if using mysql.server startup script)
'l!', # don't subtract lock time from total time 'l!', # don't subtract lock time from total time
) or die "Bad option"; ) or usage("bad option");
$opt{'help'} and usage();
unless (@ARGV) { unless (@ARGV) {
my $defaults = `my_print_defaults mysqld`; my $defaults = `my_print_defaults mysqld`;
...@@ -141,3 +143,38 @@ foreach (@sorted) { ...@@ -141,3 +143,38 @@ foreach (@sorted) {
printf "Count: %d Time=%.2fs (%ds) Lock=%.2fs (%ds) Rows=%.1f (%d), $user\@$host\n%s\n\n", printf "Count: %d Time=%.2fs (%ds) Lock=%.2fs (%ds) Rows=%.1f (%d), $user\@$host\n%s\n\n",
$c, $at,$t, $al,$l, $ar,$r, $_; $c, $at,$t, $al,$l, $ar,$r, $_;
} }
sub usage {
my $str= shift;
my $text= <<HERE;
Usage: mysqldumpslow [ OPTS... ] [ LOGS... ]
Parse and summarize the MySQL slow query log. Options are
--verbose verbose
--debug debug
--help write this text to standard output
-v verbose
-d debug
-s ORDER what to sort by (t, at, l, al, r, ar etc), 'at' is default
-r reverse the sort order (largest last instead of first)
-t NUM just show the top n queries
-a don't abstract all numbers to N and strings to 'S'
-n NUM abstract numbers with at least n digits within names
-g PATTERN grep: only consider stmts that include this string
-h HOSTNAME hostname of db server for *-slow.log filename (can be wildcard),
default is '*', i.e. match all
-i NAME name of server instance (if using mysql.server startup script)
-l don't subtract lock time from total time
HERE
if ($str) {
print STDERR "ERROR: $str\n\n";
print STDERR $text;
exit 1;
} else {
print $text;
exit 0;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment