This is a discussion on [AMaViS-user] Amavisd-new - Too many files in quarantine dir within the Amavis User forums, part of the Anti-Spam and Anti-Virus Related Forums category; This is a multi-part message in MIME format. --------------050501010106060900000409 Content-Type: text/plain; charset=ISO-8859-1; format=flowed ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
This is a multi-part message in MIME format.
--------------050501010106060900000409 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit When I started using amavisd-new, I noticed that my system was getting gradually slower and slower. I tracked it down to the quarantine directory having too many files in it. Before amavis creates a new quarantine file, it checks to make sure the file doesn't already exist. The more files in the directory, the longer it takes to do the check. I made changes to amavisd-new so that it would create subdirectories for each day/hour. This seems to solve the problem nicely, as well as having the added benefit of making it super easy to delete old quarantine files. Attached is a patch for my changes (based on amavisd-new-2.2.1), although it would be nice if the strftime format used for the 'i' variable was user configurable. Thanks, Stuart Johnston --------------050501010106060900000409 Content-Type: text/x-patch; name="quarantine_dirs.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="quarantine_dirs.patch" --- amavisd.orig 2005-02-25 15:53:50.281339872 -0600 +++ amavisd 2005-02-25 16:00:52.496153464 -0600 @@ -131,6 +131,7 @@ MIME::Decoder::Base64 MIME::Decoder::Binary MIME::Decoder::QuotedPrint MIME::Decoder::NBit MIME::Decoder::UU MIME::Decoder::Gzip64 Net::Cmd Net::SMTP Net::Server Net::Server::PreForkSimple + File::Spec File::Path )); # with earlier versions of Perl one may need to add additional modules # to the list, such as: auto::POSIX::setgid auto::POSIX::setuid ... @@ -3429,6 +3430,8 @@ use POSIX qw(strftime); use IO::File (); use IO::Wrap; +use File::Spec; +use File::Path; BEGIN { import Amavis::Conf qw(:platform $gzip $bzip2 c cr ca); @@ -3503,7 +3506,7 @@ { $suggested_filename = $via_arg ne '' ? $via_arg : 'msg-%i-%n' } $suggested_filename =~ s{%(.)} { $1 eq 'b' ? $msginfo->body_digest - : $1 eq 'i' ? strftime("%Y%m%d-%H%M%S",localtime($msginfo->rx_time)) + : $1 eq 'i' ? strftime("%Y%m%d/%H",localtime($msginfo->rx_time)) : $1 eq 'n' ? am_id() : $1 eq '%' ? '%' : '%'.$1 }egs; # one mail per file, will create specified file @@ -3519,6 +3522,8 @@ if ($errn == ENOENT) { # good, no file, as expected } elsif (!$errn && -e _) { die "File $mbxname already exists, refuse to overwrite" } + my ($v, $d, $f) = File::Spec->splitpath( $mbxname ); + mkpath $d unless (-e $d); if ($mbxname =~ /\.gz\z/) { ($mp,$pid) = run_command_consumer($mbxname,undef,$gzip); $pipe = 1; @@ -4184,7 +4189,7 @@ my($bsmtp_file_final) = $1; my($mbxname); $bsmtp_file_final =~ s{%(.)} { $1 eq 'b' ? $msginfo->body_digest - : $1 eq 'i' ? strftime("%Y%m%d-%H%M%S",localtime($msginfo->rx_time)) + : $1 eq 'i' ? strftime("%Y%m%d/%H",localtime($msginfo->rx_time)) : $1 eq 'n' ? am_id() : $1 eq '%' ? '%' : '%'.$1 }egs; # prepend directory if not specified @@ -4207,6 +4212,8 @@ $msg = IO::Wrap::wraphandle($msg); # now we have an IO::Handle-like obj $msg->seek(0,0) or die "Can't rewind mail file: $!"; } + my ($v, $d, $f) = File::Spec->splitpath( $bsmtp_file_tmp ); + mkpath $d unless (-e $d); my($mp) = IO::File->new; eval { $mp->open($bsmtp_file_tmp,'>',0640) @@ -7261,7 +7268,7 @@ $VIRUSFILE = $q_method =~ /^(?:local|bsmtp):(.*)\z/si ? $1 : "virus-%i-%n"; $VIRUSFILE =~ s{%(.)} { $1 eq 'b' ? $msginfo->body_digest - : $1 eq 'i' ? strftime("%Y%m%d-%H%M%S",localtime($msginfo->rx_time)) + : $1 eq 'i' ? strftime("%Y%m%d/%H",localtime($msginfo->rx_time)) : $1 eq 'n' ? am_id() : $1 eq '%' ? '%' : '%'.$1 }egs; do_log(5, "do_virus: looking for per-recipient quarantine and admins"); @@ -7398,7 +7405,7 @@ $VIRUSFILE = $q_method =~ /^(?:local|bsmtp):(.*)\z/si ? $1 : "spam-%b-%i-%n"; $VIRUSFILE =~ s{%(.)} { $1 eq 'b' ? $msginfo->body_digest - : $1 eq 'i' ? strftime("%Y%m%d-%H%M%S",localtime($msginfo->rx_time)) + : $1 eq 'i' ? strftime("%Y%m%d/%H",localtime($msginfo->rx_time)) : $1 eq 'n' ? am_id() : $1 eq '%' ? '%' : '%'.$1 }egs; # use the smallest value as the level reported in quarantined headers! --------------050501010106060900000409-- ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ AMaViS-user mailing list AMaViS-user@lists.sourceforge.net https://lists.sourceforge.net/lists/...fo/amavis-user AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 AMaViS-HowTos:http://www.amavis.org/howto/ |