|
Packit |
57988d |
##########################################################################
|
|
Packit |
57988d |
# $Id$
|
|
Packit |
57988d |
##########################################################################
|
|
Packit |
57988d |
|
|
Packit |
57988d |
#######################################################
|
|
Packit |
57988d |
## Copyright (c) 2008 Colin Smith <Colin.Smith@fantasie.org.uk>
|
|
Packit |
57988d |
## Covered under the included MIT/X-Consortium License:
|
|
Packit |
57988d |
## http://www.opensource.org/licenses/mit-license.php
|
|
Packit |
57988d |
## All modifications and contributions by other persons to
|
|
Packit |
57988d |
## this script are assumed to have been donated to the
|
|
Packit |
57988d |
## Logwatch project and thus assume the above copyright
|
|
Packit |
57988d |
## and licensing terms. If you want to make contributions
|
|
Packit |
57988d |
## under your own copyright or a different license this
|
|
Packit |
57988d |
## must be explicitly stated in the contribution an the
|
|
Packit |
57988d |
## Logwatch project reserves the right to not accept such
|
|
Packit |
57988d |
## contributions. If you have made significant
|
|
Packit |
57988d |
## contributions to this script and want to claim
|
|
Packit |
57988d |
## copyright please contact logwatch-devel@lists.sourceforge.net.
|
|
Packit |
57988d |
#########################################################
|
|
Packit |
57988d |
|
|
Packit |
57988d |
use strict;
|
|
Packit |
57988d |
use POSIX;
|
|
Packit |
57988d |
|
|
Packit |
57988d |
my $SPOOLDIR = '';
|
|
Packit |
57988d |
my $sizethresh = defined $ENV{sendmail_largeboxes_size} ? uc $ENV{sendmail_largeboxes_size} : 40960000;
|
|
Packit |
57988d |
my $title = "Large Mailbox threshold: $sizethresh";
|
|
Packit |
57988d |
my $sizebytes = $sizethresh;
|
|
Packit |
57988d |
if ($sizethresh =~ /^(\d+)TB?$/i) {
|
|
Packit |
57988d |
$sizebytes = $1 * 1024 ** 4;
|
|
Packit |
57988d |
} elsif ($sizethresh =~ /^(\d+)GB?$/i) {
|
|
Packit |
57988d |
$sizebytes = $1 * 1024 ** 3;
|
|
Packit |
57988d |
} elsif ($sizethresh =~ /^(\d+)MB?$/i) {
|
|
Packit |
57988d |
$sizebytes = $1 * 1024 ** 2;
|
|
Packit |
57988d |
} elsif ($sizethresh =~ /^(\d+)KB?$/i) {
|
|
Packit |
57988d |
$sizebytes = $1 * 1024;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
$title .= ($sizethresh ne $sizebytes) ? " ($sizebytes bytes)\n" : "\n";
|
|
Packit |
57988d |
|
|
Packit |
57988d |
# $hostname may be fully-qualified name
|
|
Packit |
57988d |
my ($OSname, $hostname, $release, $version, $machine) = POSIX::uname();
|
|
Packit |
57988d |
$hostname =~ s/\..*//;
|
|
Packit |
57988d |
exit (0) if ($ENV{'LOGWATCH_ONLY_HOSTNAME'} and ($ENV{'LOGWATCH_ONLY_HOSTNAME'} ne $hostname));
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if (-e "/var/mail") {
|
|
Packit |
57988d |
$SPOOLDIR = "/var/mail";
|
|
Packit |
57988d |
} elsif ( -e "/var/spool/mail") {
|
|
Packit |
57988d |
$SPOOLDIR = "/var/spool/mail";
|
|
Packit |
57988d |
} else {
|
|
Packit |
57988d |
print "Can't find spool directory\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ($SPOOLDIR) {
|
|
Packit |
57988d |
opendir(DIR, "$SPOOLDIR") || die "Can not opendir $SPOOLDIR: $!\n";
|
|
Packit |
57988d |
my @files = grep {!/^\./} readdir(DIR);
|
|
Packit |
57988d |
closedir DIR;
|
|
Packit |
57988d |
|
|
Packit |
57988d |
for my $filename (@files) {
|
|
Packit |
57988d |
my $checksize = (stat("$SPOOLDIR/$filename"))[7];
|
|
Packit |
57988d |
if ($checksize >= $sizebytes) {
|
|
Packit |
57988d |
print "$title Warning: Large mailbox: $filename ($checksize)\n";
|
|
Packit |
57988d |
$title = ""; # only print at start of report
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
# vi: shiftwidth=3 tabstop=3 syntax=perl et
|
|
Packit |
57988d |
# Local Variables:
|
|
Packit |
57988d |
# mode: perl
|
|
Packit |
57988d |
# perl-indent-level: 3
|
|
Packit |
57988d |
# indent-tabs-mode: nil
|
|
Packit |
57988d |
# End:
|