Script to do mysqcheck

#!/usr/bin/perl
# this script can be run by command line to check each table on every database on every databases

my $a = `hostname`;
my @dbs =`mysql -u root -p[password] -e "show databases" | grep -v "Database" `;


foreach $i(@dbs){
chomp($i);
my @aa = `mysql -u root -p[password] $i -e 'show tables' |grep -v 'Tables_in_'`;
next if ($i =~/Tables_in_$i/);
foreach $r(@aa) {
chomp($r) ;
$d = `mysqlcheck -u root -p[password] $i $r` ;
print "checking table = $r of database $i \n";
if ($d =~/error/ ) {
print " the table $i is corrupted \n";
system(`/usr/local/bin/smtpmail -t a\@alertme.com -f admin\@serverone.com -h 192.168.2.105 -s "th table is courupted" -b "the table is $r of database $i on server $a is courrupted ..kindly check" `) ;

}
}
}

No comments:

Other Articles

Enter your email address: