The problem

So.. I had an issue where I had to stress test a new MTA I was deploying. Generating load so I can tweak the config was key.. here’s a handy way to do it.

Behavior:

27% chance of sending a 37,597 byte message with an attachment
17% chance of sending a 3,075 byte message
16% chance of sending a 7,108 byte message
10% chance of sending a 14,743 byte message
6% chance of sending a 547 byte message
6% chance of sending a 60,969 byte message with an attachment
4% chance of sending a 124,167 byte message with an attachment
3% chance of sending a 85,993 byte message with an attachment
2% chance of sending a 171,358 byte message with an attachment
2% chance of sending a 221,826 byte message with an attachment
1% chance of sending a 274,007 byte message with an attachment
1% chance of sending a 313,479 byte message with an attachment
1% chance of sending a 416,983 byte message with an attachment
1% chance of sending a 550,839 byte message with an attachment
1% chance of sending a 761,659 byte message with an attachment
1% chance of sending a 1,214,991 byte message with an attachment
1% chance of sending a 5,505,014 byte message with an attachment

Generate Test Files:

dd if=/dev/urandom of=4031 bs=1 count=4031
dd if=/dev/urandom of=6281 bs=1 count=6281
dd if=/dev/urandom of=18123 bs=1 count=18123
dd if=/dev/urandom of=230 bs=1 count=230
#attachments
dd if=/dev/urandom of=24987.doc bs=1 count=24987
dd if=/dev/urandom of=80234.doc bs=1 count=80234
dd if=/dev/urandom of=112167.doc bs=1 count=112167
dd if=/dev/urandom of=89941.doc bs=1 count=89941
dd if=/dev/urandom of=149344.doc bs=1 count=149344
dd if=/dev/urandom of=221826.doc bs=1 count=221826
dd if=/dev/urandom of=274007.doc bs=1 count=274007
dd if=/dev/urandom of=313479.doc bs=1 count=313479
dd if=/dev/urandom of=416983.doc bs=1 count=416983
dd if=/dev/urandom of=550839.doc bs=1 count=550839
dd if=/dev/urandom of=761659.doc bs=1 count=761659
dd if=/dev/urandom of=1214991.doc bs=1 count=1214991
dd if=/dev/urandom of=5505014.doc bs=1 count=5505014

The Script to Stress Test your Relay:

#!/bin/ksh

if [ -z “$1” ] ; then
echo “Usage: $0 messagecount”
exit 1
fi

# $Absolute path to mutt (mail agent)
MUTT=/usr/bin/mutt

# destination email addresses
RECIPIENTS=null@null.com

COUNTER=0

while [ “$COUNTER” -lt $1 ]
do
RN=`echo $(( RANDOM % 100 + 1))`
if [ $RN -ge 1 -a $RN -le 27 ] ; then
$MUTT -a 24987.doc — $RECIPIENTS < “.”
elif [ $RN -ge 28 -a $RN -le 44 ] ; then
$MUTT -i 4031 $RECIPIENTS < “.”
elif [ $RN -ge 45 -a $RN -le 60 ] ; then
$MUTT -i 6281 $RECIPIENTS < “.”
elif [ $RN -ge 61 -a $RN -le 70 ] ; then
$MUTT -i 18123 $RECIPIENTS < “.”
elif [ $RN -ge 71 -a $RN -le 76 ] ; then
$MUTT -i 230 $RECIPIENTS < “.”
elif [ $RN -ge 77 -a $RN -le 82 ] ; then
$MUTT -a 80234.doc — $RECIPIENTS < “.”
elif [ $RN -ge 83 -a $RN -le 86 ] ; then
$MUTT -a 112167.doc — $RECIPIENTS < “.”
elif [ $RN -ge 87 -a $RN -le 89 ] ; then
$MUTT -a 89941.doc — $RECIPIENTS < “.”
elif [ $RN -ge 90 -a $RN -le 91 ] ; then
$MUTT -a 149344.doc — $RECIPIENTS < “.”
elif [ $RN -ge 92 -a $RN -le 93 ] ; then
$MUTT -a 221826.doc — $RECIPIENTS < “.”
elif [ $RN -eq 94 ] ; then
$MUTT -a 274007.doc — $RECIPIENTS < “.”
elif [ $RN -eq 95 ] ; then
$MUTT -a 313479.doc — $RECIPIENTS < “.”
elif [ $RN -eq 96 ] ; then
$MUTT -a 416983.doc — $RECIPIENTS < “.”
elif [ $RN -eq 97 ] ; then
$MUTT -a 550839.doc — $RECIPIENTS < “.”
elif [ $RN -eq 98 ] ; then
$MUTT -a 761659.doc — $RECIPIENTS < “.”
elif [ $RN -eq 99 ] ; then
$MUTT -a 1214991.doc — $RECIPIENTS < “.”
elif [ $RN -eq 100 ] ; then
$MUTT -a 5505014.doc — $RECIPIENTS < “.”
fi

# add counter
COUNTER=`expr $COUNTER + 1`

done

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s