-
Notifications
You must be signed in to change notification settings - Fork 1
/
siege.sh
executable file
·57 lines (48 loc) · 1.43 KB
/
siege.sh
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
#!/usr/bin/env bash
SERVER=${SERVER:-10.66.66.32:30001}
#
# Start user session.
#
curl -s -c cookies.txt -H 'Authorization: Basic dXNlcjpwYXNzd29yZA==' \
$SERVER/login > /dev/null
logdn=$(cat cookies.txt | tail -n 2 | head -n 1 | awk '{print $6"="$7}')
mdsid=$(cat cookies.txt | tail -n 1 | awk '{print $6"="$7}')
cooke="Cookie: $logdn; $mdsid"
#
# Add item to cart.
#
curl -XPOST -b cookies.txt -H 'Content-Type: application/json' \
-d '{"id":"510a0d7e-8e83-4193-b483-e27e09ddc34d"}' \
$SERVER/cart
#
# Start CPU and RAM monitoring.
#
./rammon.sh &
./cpumon.sh &
#
# Checkout
#
for i in {1..1000}; do
if [[ $i == 250 || $i == 500 || $i == 750 ]]; then
curl -s -c cookies.txt -H 'Authorization: Basic dXNlcjpwYXNzd29yZA==' \
$SERVER/login > /dev/null
logdn=$(cat cookies.txt | tail -n 2 | head -n 1 | awk '{print $6"="$7}')
mdsid=$(cat cookies.txt | tail -n 1 | awk '{print $6"="$7}')
cooke="Cookie: $logdn; $mdsid"
curl -XPOST -b cookies.txt -H 'Content-Type: application/json' \
-d '{"id":"510a0d7e-8e83-4193-b483-e27e09ddc34d"}' \
$SERVER/cart
fi
curl -XPOST \
-s \
-b cookies.txt \
-w "%{time_total},%{http_code}\n" \
-o /dev/null \
$SERVER/orders >> log.csv
sleep $(Rscript ./generate_random_number.r | awk {'print $2'})
done
#
# Kill monitoring processes.
#
ps aux | grep cpumon | awk 'NR==1{print $1}' | xargs kill -9
ps aux | grep rammon | awk 'NR==1{print $1}' | xargs kill -9