File: //proc/self/root/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;
}
}