Created
August 25, 2014 04:21
-
-
Save hexatridecimal/08b2c51c8d2e15ae171b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use DBI; | |
use Data::Dumper qw/Dumper/; | |
my $query = shift(@ARGV); | |
my $dbh = DBI->connect('dbi:mysql:database=', 'root', 'YoPassword'); | |
my $sth = $dbh->prepare("SHOW PROCESSLIST"); | |
while (1) { | |
$sth->execute(); | |
my $ret = $sth->fetchall_arrayref(); | |
$found = 0; | |
foreach my $row (@$ret) { | |
if ($row->[7] =~ /$query/) { | |
$found = 1; | |
} | |
} | |
if ($found == 0) { | |
print "Not found!\a\n"; | |
} else { | |
print "Yup, still running!\n"; | |
} | |
sleep(5); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've found this really useful. Use like:
./watch_mysql.pl "alter table x"
This will ring a bell when the query finishes.