|
Server : Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 System : Linux server.jackjohnson.com 2.6.32-279.5.2.el6.x86_64 #1 SMP Fri Aug 24 01:07:11 UTC 2012 x86_64 User : jackjohn ( 502) PHP Version : 5.3.17 Disable Function : NONE Directory : /scripts/ |
Upload File : |
#!/usr/local/cpanel/3rdparty/bin/perl
# cpanel - scripts/slurp_exim_mainlog Copyright(c) 2011 cPanel, Inc.
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
package cpanel::scripts::slurp_exim_mainlog;
use Cpanel::FileUtils::TouchFile;
use Cpanel::Sys::Setsid ();
use strict;
__PACKAGE__->script(@ARGV) unless caller();
## CAVEATS re: case 53744
## 1. the eximstats schema handles dedupes, so we process all recent files
## 2. TaskQueue is overkill for this one-time slurp
sub script {
my ( $class, @argv ) = @_;
## skip the one-time slurp of exim_mainlog* if this file exists
my $touchfile = '/var/cpanel/version/eximstats_imported';
return if ( -e $touchfile );
my $time = time();
my @imports;
my $logdir = '/var/log/';
if ( opendir( my $dh, $logdir ) ) {
for my $log ( grep { m/^exim_mainlog/ } sort readdir($dh) ) {
my $age = ( stat("$logdir/$log") )[9];
## eximstats shows info for 60 days
next if ( $time - $age > 60 * 60 * 24 * 60 );
push( @imports, "$logdir/$log" );
}
closedir($dh);
}
if ( my $pid = fork() ) {
Cpanel::FileUtils::TouchFile::touchfile($touchfile);
}
else {
Cpanel::Sys::Setsid::fast_setsid();
close(STDIN);
close(STDOUT);
close(STDERR);
open( STDIN, "<", " /dev/null" );
open( STDOUT, ">", "/dev/null" );
open( STDERR, ">", "/dev/null" );
exec( '/usr/local/cpanel/scripts/import_exim_data', @imports );
}
}