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/biglogcheck
#!/usr/bin/perl
# cpanel - biglogcheck                            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 strict;
use Cpanel::iContact ();

my $msg;
my @logdirs = qw( /usr/local/apache/domlogs /usr/local/apache/logs /usr/local/cpanel/logs /var/log );

foreach my $logdir (@logdirs) {
    if ( -d $logdir ) {
        open( DU, "du -La $logdir |" );
        while (<DU>) {
            my ( $size, $file ) = split( /\s+/, $_ );
            if ( $size > 1650000 ) {
                next if $file =~ m/\.(?:gz|bz2|tar|zip)$/;
                next if -d $file;
                my $nicesize = ( $size / 1024 );
                $msg .= "$file ($nicesize Megs)\n";
            }
        }
        close(DU);
    }
}

if ($msg) {
    my $message = <<"EOM";

The following log files are nearing the 2 gigabyte file limit.
You should recycle them or remove them to prevent apache from
getting SIGXFSZ (File Size Exceeded)


=======================================================

$msg

EOM
    Cpanel::iContact::icontact(
        'application' => 'biglogcheck',
        'level'       => 1,
        'subject'     => '[biglogcheck] Log Files Nearing 2 Gigabytes',
        'message'     => $message
    );
    if ( $ARGV[0] eq '-v' ) {
        print $message;
    }
}