2
# mysqldumpslow - parse and summarize the MySQL slow query log
2
# drizzledumpslow - parse and summarize the Drizzle slow query log
4
4
# Original version by Tim Bunce, sometime in 2000.
5
5
# Further changes by Tim Bunce, 8th March 2001.
27
27
'n=i', # abstract numbers with at least n digits within names
28
28
'g=s', # grep: only consider stmts that include this string
29
29
'h=s', # hostname of db server for *-slow.log filename (can be wildcard)
30
'i=s', # name of server instance (if using mysql.server startup script)
30
'i=s', # name of server instance (if using drizzle.server startup script)
31
31
'l!', # don't subtract lock time from total time
32
32
) or usage("bad option");
34
34
$opt{'help'} and usage();
37
my $defaults = `my_print_defaults mysqld`;
37
my $defaults = `my_print_defaults drizzled`;
38
38
my $basedir = ($defaults =~ m/--basedir=(.*)/)[0]
39
or die "Can't determine basedir from 'my_print_defaults mysqld' output: $defaults";
39
or die "Can't determine basedir from 'my_print_defaults drizzled' output: $defaults";
40
40
warn "basedir=$basedir\n" if $opt{v};
42
42
my $datadir = ($defaults =~ m/--datadir=(.*)/)[0];
43
my $slowlog = ($defaults =~ m/--log-slow-queries=(.*)/)[0];
43
my $slowlog = ($defaults =~ m/--log[_-]slow[_-]queries=(.*)/)[0];
44
44
if (!$datadir or $opt{i}) {
45
45
# determine the datadir from the instances section of /etc/my.cnf, if any
46
46
my $instances = `my_print_defaults instances`;
47
die "Can't determine datadir from 'my_print_defaults mysqld' output: $defaults"
47
die "Can't determine datadir from 'my_print_defaults drizzled' output: $defaults"
49
49
my @instances = ($instances =~ m/^--(\w+)-/mg);
50
50
die "No -i 'instance_name' specified to select among known instances: @instances.\n"
87
87
my ($t, $l, $r) = ($1, $2, $3);
88
88
$t -= $l unless $opt{l};
90
# remove fluff that mysqld writes to log when it (re)starts:
90
# remove fluff that drizzled writes to log when it (re)starts:
91
91
s!^/.*Version.*started with:.*\n!!mg;
92
92
s!^Tcp port: \d+ Unix socket: \S+\n!!mg;
93
93
s!^Time.*Id.*Command.*Argument.*\n!!mg;
155
155
my $text= <<HERE;
156
Usage: mysqldumpslow [ OPTS... ] [ LOGS... ]
156
Usage: drizzledumpslow [ OPTS... ] [ LOGS... ]
158
Parse and summarize the MySQL slow query log. Options are
158
Parse and summarize the Drizzle slow query log. Options are
160
160
--verbose verbose
171
171
-g PATTERN grep: only consider stmts that include this string
172
172
-h HOSTNAME hostname of db server for *-slow.log filename (can be wildcard),
173
173
default is '*', i.e. match all
174
-i NAME name of server instance (if using mysql.server startup script)
174
-i NAME name of server instance (if using drizzle.server startup script)
175
175
-l don't subtract lock time from total time