Skip to content

Instantly share code, notes, and snippets.

@hsiboy
Created May 6, 2014 09:51
Show Gist options
  • Save hsiboy/d6a8dc7802b0025bbf66 to your computer and use it in GitHub Desktop.
Save hsiboy/d6a8dc7802b0025bbf66 to your computer and use it in GitHub Desktop.
Prepares IIS W3C log files for use with siege
#!/bin/bash
#
# Takes IIS W3C formatted log files, and creates a load file for use with siege.
#
#
# make sure you always put $f in double quotes to avoid any nasty surprises i.e. "$f"
for f in $@
do
echo "Processing $f..."
# dos 2 unix, remove comments, remove empty lines
sed -i -e 's/.$//' -e 's/#.*//' -e '/^$/ d' "$f"
# only requests that didnt throw an error
awk -F ' ' '$12 < 400 {print}' $f > uri
# only want uri and request method
cut -d' ' -f4-5 uri > method_uri
rm uri
# strip out load balancer check
grep -v "/load/balancer/check.html" method_uri > urls
# i just want GETs
grep "GET" urls > urls.txt
rm method_uri
rm urls
#TODO: add load balancer check every 200 requests
#awk '1;!(NR%200){print "GET /load/balancer/check.html";}' file
# prep for siege
sed -i -e 's/GET /http:\/\/siege-target.domain.com/' urls.txt
echo "Setting dates in URI to `date +%Y%m%d`\n"
# update the form submitted dates to today
sed -i -e 's/d=[0-9]\{8\}/d='`date +%Y%m%d`'/g' urls.txt
split -l 100000 urls.txt SiegeUrls.
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment