Siege allows you to write a list of URLs in a file (one URL per line) the utility will then parse the file and execute the load tests according to your configuration file .siegerc or the command's arguments.
The only thing I do not like about siege is the fact that I would like to have stats per URL; when siege parses the url file it will write a log file with global statics for the siege session
Something like so :
1 |
2012-09-21 12:03:52, 1813, 121.43, 19, 0.49, 14.93, 0.16, 7.38, 1813, 0 |
which to my taste is not very clear
While executing the tests siege prints out statistics that are not found in the siege log file (which in my case are more useful) but if you have multiple URLs you don't know for which URL the printed stats are.
So I decided to handle the situation differently using awk and a bash script
Note that I'm no Linux expert so the script could probably be better written but here is how I broke it down :
I have 3 files
- The urls.txt file (a txt file containing the URLs I want to test :
- The AWK script file
- The bash script containing all the configuration and calling the awk script
1 2 3 4 5 6 7 8 9 10 11 |
!/#/{ print "\n" print "**********************************************************" print "Testing URL : "$1 print "**********************************************************" system ("echo Testing URL : "$1 " >> " SIEGE_OUTPUT " 2>&1") system ("siege " $1 "-v -b -r"REPS" -c"CONC" --mark="$1 " --log="SIEGE_LOG_FILE ">> "SIEGE_OUTPUT " 2>&1 ") print "\n"} |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#! /bin/sh#LOG_FILE=./siege-logURL_FILE=./urls.txt # file containing the URLs to handleUSER=$(whoami)NOW=$(date +"%d-%m-%Y_%H-%M-%S")PWD=$(pwd)SIEGE_LOG_FILE=$PWD"/log_"$NOW".log" #siege log's fileSIEGE_OUTPUT=$PWD"/output_"$NOW".log" #where siege's output will be redirectedCONC=50 #number of concurrent usersREPS=1 # number of repetitionsecho "loading URLS from the file : "$URL_FILEecho "Writing siege log into the file :" $SIEGE_LOG_FILESET -- $CONCawk -f siege-benchmark.awk -v CONC=$CONC REPS=$REPS SIEGE_LOG_FILE=$SIEGE_LOG_FILE SIEGE_OUTPUT=$SIEGE_OUTPUT $URL_FILE |
Now according to how your siegerc file is configured output can be a bit different I have the verbose mod off and benchmark mode on. Below is an excerpt from my log file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
******************************************Testing URL : http://myURL1/param1/param2.json******************************************** SIEGE 2.72** Preparing 50 concurrent users for battle.The server is now under siege...Transactions: 50 hitsAvailability: 100.00 %Elapsed time: 0.08 secsData transferred: 0.00 MBResponse time: 0.04 secsTransaction rate: 625.00 trans/secThroughput: 0.03 MB/secConcurrency: 24.62Successful transactions: 50Failed transactions: 0Longest transaction: 0.07Shortest transaction: 0.01 |