MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
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();
    };
}