Search through options to find where the slow query log actually is.

This commit is contained in:
mtaylor@qualinost.(none) 2006-12-18 21:12:01 -08:00
parent 373e280eb3
commit 09591de344

View File

@ -40,6 +40,7 @@ unless (@ARGV) {
warn "basedir=$basedir\n" if $opt{v}; warn "basedir=$basedir\n" if $opt{v};
my $datadir = ($defaults =~ m/--datadir=(.*)/)[0]; my $datadir = ($defaults =~ m/--datadir=(.*)/)[0];
my $slowlog = ($defaults =~ m/--log-slow-queries=(.*)/)[0];
if (!$datadir or $opt{i}) { if (!$datadir or $opt{i}) {
# determine the datadir from the instances section of /etc/my.cnf, if any # determine the datadir from the instances section of /etc/my.cnf, if any
my $instances = `my_print_defaults instances`; my $instances = `my_print_defaults instances`;
@ -55,9 +56,14 @@ unless (@ARGV) {
warn "datadir=$datadir\n" if $opt{v}; warn "datadir=$datadir\n" if $opt{v};
} }
if ( -f $slowlog ) {
@ARGV = ($slowlog);
die "Can't find '$slowlog'\n" unless @ARGV;
} else {
@ARGV = <$datadir/$opt{h}-slow.log>; @ARGV = <$datadir/$opt{h}-slow.log>;
die "Can't find '$datadir/$opt{h}-slow.log'\n" unless @ARGV; die "Can't find '$datadir/$opt{h}-slow.log'\n" unless @ARGV;
} }
}
warn "\nReading mysql slow query log from @ARGV\n"; warn "\nReading mysql slow query log from @ARGV\n";