chore: add icecast stress script ()

This commit is contained in:
Jonas L 2022-09-27 08:10:37 +02:00 committed by GitHub
parent 782500f76f
commit 2efe714b03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 0 deletions

36
tools/icecast-stress.sh Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -eu
error() {
echo >&2 "error: $*"
exit 1
}
command -v curl > /dev/null || error "curl command not found!"
# Run concurrent curls which download from url to /dev/null.
url="$1"
# max concurrent calls
max=1000
# call duration (in seconds)
duration=100
# number of calls to start in batch
batch=10
# time to wait before starting a new batch of calls (in seconds)
delay=1
count=0
while [[ "$count" -le "$max" ]]; do
echo "starting $batch new calls ($count)"
for ((i = 1; i <= batch; i++)); do
curl -o /dev/null -m "$duration" -s "$url" &
done
count=$((count + batch))
sleep "$delay"
done
echo "waiting for calls to finish"
wait
echo "done"