Skip to content

Instantly share code, notes, and snippets.

@richardbenson
Created February 24, 2012 13:57
Show Gist options
  • Save richardbenson/1901091 to your computer and use it in GitHub Desktop.
Save richardbenson/1901091 to your computer and use it in GitHub Desktop.
Script beeswithmachineguns
#!/bin/sh
REQUESTS=10000
COUNT=250
BEES=4
KEYNAME=<whateveryourkey.pem is>
GROUP=public
while getopts "h:r:c:b:" opt; do
case $opt in
h)
HOST=$OPTARG
;;
r)
REQUESTS=$OPTARG
;;
c)
COUNT=$OPTARG
;;
b)
BEES=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
if [ -n $host ]; then
echo "****************************"
echo "Sending a swarm to $HOST."
echo "$BEES will be created, sending $REQUESTS requests"
echo "with a maximum concurrency of $COUNT per bee."
echo "****************************\n\n"
# start up the bees
echo "----------------------------"
echo "STARTING UP BEES"
echo "----------------------------"
bees up -s $BEES -g $GROUP -k $KEYNAME
sleep 90 #EC2 can take an age to actually allow you to connect to your instances
# begin the attack
echo "\n\n"
echo "----------------------------"
echo "BEGINNING THE ATTACK"
echo "----------------------------"
bees attack -n $REQUESTS -c $COUNT -u $HOST
sleep 5
# stand down bees
echo "\n\n"
echo "----------------------------"
echo "TAKING DOWN SWARM"
echo "----------------------------"
bees down
else
echo "No host (-h) specified" >&2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment