-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstress_test.sh
executable file
·47 lines (40 loc) · 1.07 KB
/
stress_test.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
#!/bin/bash
# Create logs directory and set permissions
mkdir -p logs
chmod 755 logs
# Ensure monitor_memory.sh is executable
chmod +x monitor_memory.sh
# Check if server is running
if ! nc -z localhost 8080; then
echo "Error: Web server is not running on port 8080"
echo "Please start the server first with: ./webserv config/default.conf"
exit 1
fi
# Start monitoring
./monitor_memory.sh &
monitor_pid=$!
# Run siege test with correct URL format
echo "Starting siege test..."
siege -b -t60S http://127.0.0.1:8080/empty.html
# Cleanup
if [ ! -z "$monitor_pid" ]; then
kill $monitor_pid 2>/dev/null || true
fi
# Analyze results
echo "Analyzing memory usage..."
if [ -f logs/memory_log.csv ]; then
awk -F',' '{
if(NR>1) {
if($2 > max) max=$2
if(min=="" || $2 < min) min=$2
sum+=$2; count++
}
}
END {
print "Min Memory: "min" KB"
print "Max Memory: "max" KB"
print "Avg Memory: "sum/count" KB"
}' logs/memory_log.csv
else
echo "No memory log found at logs/memory_log.csv"
fi