File: //scripts.20110531.215904.25158/optimize_eximstats
#!/usr/bin/perl
# cpanel - optimize_eximstats Copyright(c) 2010 cPanel, Inc.
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
BEGIN { unshift @INC, '/usr/local/cpanel'; }
use Cpanel::MysqlUtils ();
my $hasmysql = 0;
eval {
require DBD::mysql;
$hasmysql = 1;
};
if ($hasmysql) {
my $dbpassword = Cpanel::MysqlUtils::getmydbpass('root'); #read from /root/.my.cnf
my $host = Cpanel::MysqlUtils::getmydbhost('root') || 'localhost';
exit if !$dbpassword;
eval {
local $SIG{"ALRM"} = sub {
die "mysql connection timed out\n";
};
alarm(30);
my $dbh = DBI->connect( "DBI:mysql:mysql:$host", 'root', $dbpassword );
alarm(0);
unless ($dbh) {
die("Can't Connect");
}
$dbh->do('OPTIMIZE TABLE eximstats.sends, eximstats.smtp;');
$dbh->disconnect();
};
}