Last active
August 29, 2015 14:06
-
-
Save billyriantono/294188a0364fafb6872a to your computer and use it in GitHub Desktop.
Simpler Siege
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Simpler Script to running Siege | |
# by Billy Riantono - billy[ at ]riantono.com | |
#function | |
ok() { echo -e '\e[32m'$1'\e[m'; } # Green | |
#Download Siege | |
ok "Checking Siege ...." | |
if [ ! -f /usr/bin/siege ]; then | |
ok "Siege Not Found , it will be automatically install Siege"; | |
sudo apt-get install -f siege | |
fi | |
ok "Checking Siege Finish"; | |
#reading options | |
while getopts ":u:c:h:f:r:" optchar ; do | |
case $optchar in | |
u) URL=${OPTARG} ;; | |
c) CONCURRENT=${OPTARG};; | |
h) HEADERS=${OPTARG};; | |
f) LOG_FILE=${OPTARG};; | |
r) REPS=${OPTARG};; | |
*) ok "Usage $0 [-u] [-c] [-r] [-h] [-f]" ;; | |
esac | |
done | |
#parsing supplied headers | |
OIFS=$IFS; | |
IFS="|"; | |
animalArray=($HEADERS); | |
for ((i=0; i<${#animalArray[@]}; ++i)); | |
do | |
ok "${animalArray[$i]}" | |
HEADER="$HEADER --header=\"${animalArray[$i]}\""; | |
done | |
IFS=$OIFS; | |
ok "Preparing Running Siege" | |
ok "Siege Started" | |
ok "Running Siege using Command : siege --concurrent=$CONCURRENT --reps=$REPS $HEADER $URL --log=$LOG_FILE" | |
`siege --concurrent=$CONCURRENT --reps=$REPS $HEADER $URL --log=$LOG_FILE` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment