You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Francesco Potorti` <po...@potorti.it> on 2004/11/07 01:42:26 UTC
a procmail rule with a dynamic timeout
Works on Sun. Timeout is lower with greater load average.
TIMEOUT=250 ## don't wait too long for children
SHELL=/usr/local/bin/bash ## it was set to the user's shell
EX_TEMPFAIL=75 # temporary failure: requeue
SPAMC=/usr/local/bin/spamc
SOCKETPATH=/var/spool/spamassassin/spamd-3.0.socket
SPAMCOPTS="-x -U $SOCKETPATH"
n="
" # newline, for LOG messages
## Compute a dynamic timeout depending on the one-minute load average
timeout=60
#timeout=`uptime|awk '{ x=$(NF-2); print x 15+int(200/(substr(x,1,length(x)-1)+0.1)) }'`
timeout=`set - $(uptime) && shift $(($#-3)) && x=10#${1//[.,]/} && echo $((15+20000/(x+10))) || echo 50`
maxsize=150000 # do not filter messages above this size
:0 fW
| $SPAMC $SPAMCOPTS -t $timeout -s $maxsize -u $LOGNAME
:0 e # failing because of timeout or system error
* !> $maxsize
{
## After an error or timeout we can either tell sendmail to requeue the
## message, by failing with EX_TEMPFAIL, or else give up and deliver an
## unfiltered message.
#
#timeout_behaviour=riaccoda # requeue the message
timeout_behaviour=consegna # deliver the unfiltered message
:0
* timeout_behaviour ?? riaccoda
# We want to requeue the message to sendmail for later processing
{
LOG="----> errore o timeout ($timeout s) per $LOGNAME: rinuncio e riaccodo$n"
EXITCODE=$EX_TEMPFAIL # Means: retry later; requeue
:0
#$INSPECTION.timeout # inspection copy
/dev/null # discard
}
:0 E
{
# We want to get rid of the message immediately, so we deliver it unfiltered
LOG="----> errore o timeout ($timeout s) per $LOGNAME: rinuncio e non filtro$n"
}
}