2024-09-27 10:45:15 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -o nounset
|
|
|
|
set -o pipefail
|
|
|
|
if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace; fi
|
|
|
|
|
|
|
|
RATE_CHANGE_FACTOR=$1
|
|
|
|
IFS=" " read -r -a OPTS <<< $2
|
|
|
|
URL=${OPTS[0]}; METHOD=${OPTS[1]}; RATE=${OPTS[2]}; BODY=${OPTS[3]}
|
|
|
|
SLEEP_TIME=$(expr 60 / $RATE / $RATE_CHANGE_FACTOR)
|
|
|
|
|
|
|
|
until false
|
|
|
|
do
|
|
|
|
curl --header "Content-Type: application/json" \
|
|
|
|
--data $BODY \
|
|
|
|
-X $METHOD \
|
|
|
|
-s $URL \
|
|
|
|
-o /dev/null
|
2024-09-27 13:15:36 +00:00
|
|
|
if [ $? -eq 0 ]
|
|
|
|
then
|
|
|
|
printf '%s' "."
|
|
|
|
else
|
|
|
|
printf '%s' "x"
|
|
|
|
fi
|
2024-09-27 10:45:15 +00:00
|
|
|
sleep $SLEEP_TIME
|
|
|
|
done
|