File: bombardment.in

package info (click to toggle)
siege 4.0.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,624 kB
  • ctags: 1,347
  • sloc: ansic: 12,638; sh: 9,115; makefile: 155; php: 142
file content (105 lines) | stat: -rw-r--r-- 3,096 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh
#bombardment is a script that invokes siege with an ever-increasing
#number of users.
#Copyright (C) 2001 Peter J. Hutnick

#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, US

#For informaion, write the author, Peter Hutnick at phutnick@aperian.com.


# Display help if no options or --help specified.
if [ -z $1 ] || [ $1 = --help ]
	then 	
		echo ""
		echo "usage:"
		echo "bombardment [urlfile] [inital # of clients] \
[inc value] [# of inc] [delay]"
		echo ""
#		echo "so \"laysiege foo.com 10 5 3\" would test \
#http:\\\\foo.com\\index.html with 10 then 15 then 20 clients."
		echo ""
		exit
	fi

# Assign args to useful variables.
site=$1
startcl=$2
inc=$3
numruns=$4
delay=$5
serial=`date --iso-8601=minutes`

# This script can easily be made to overwhelm system resources (processes
# and filehandles.  This bit calculates how many processes it will spawn
# on the last run, and warn if it is more than 600.

total=$startcl
sub=`expr $inc \* $numruns`
total=$total+$sub

if [ 600 -lt $(($total)) ]
	then
		echo "The options you specified will generate more than \
600 concurrent users.  This causes problems on many systems.  Press \
<ctrl><c> to abort, unless you are sure your system can handle more than \
600 processes and more than 2048 open files, AND that your user account \
is allowed to do so."
		echo ""
		echo "Siege will run with the supplied options in 10 sec."
# I would rather use something like "pause" from DOS than the sleep below,
# but I don't know of any such thing.
		sleep 10
	fi



# Set a default delay of 15 seconds if none is specified.
if [ -z $5 ]
	then
		delay=15
	fi
#echo $delay


# Find the number of URLs so we can set -t in siege.  This deviates
# somewhat from Siege's normal mode of operation.  I assume that each
# entry in the URL list should be hit once per client.

numurls=`cat $site | grep -v "#" | wc -l`
# Debug-o-rama
#echo "the number of URLs is: "
#echo $numurls
#echo "\n"

# Now we come to the loop that actually runs Siege.  This sould be
# self-explainitory.

currentcl=$startcl # set running count of clients to inital value

i=1
while [ $numruns -ge $i ]
	do
		echo "Starting run number" $i
		%_PREFIX%/siege -f $site -c $currentcl -t $numurls -d $delay >> siege.$serial
        currentcl=$(($currentcl+$inc))
		i=$(($i+1))
		#sleep 30
	done

# Finally, we call siege2csv.pl to convert all the human-readable Siege
# output to CSV, for easy spreadsheet usage.
 
siege2csv siege.$serial