2019-10-03 08:48:33 +07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
echo -e '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #'
|
|
|
|
echo -e '# Yet-Another-Bench-Script #'
|
|
|
|
echo -e '# v2019-10-02 #'
|
|
|
|
echo -e '# https://github.com/masonr/yet-another-bench-script #'
|
|
|
|
echo -e '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #'
|
|
|
|
|
|
|
|
DATE=`date -Iseconds`
|
|
|
|
IPERF_PATH=/tmp/$DATE/iperf
|
|
|
|
mkdir -p $IPERF_PATH
|
|
|
|
wget -O $IPERF_PATH/libiperf.so.0 https://iperf.fr/download/ubuntu/libiperf.so.0_3.1.3 -o /dev/null
|
|
|
|
wget -O $IPERF_PATH/iperf3 https://iperf.fr/download/ubuntu/iperf3_3.1.3 -o /dev/null
|
|
|
|
chmod +x $IPERF_PATH/iperf3
|
|
|
|
|
2019-10-03 09:51:36 +07:00
|
|
|
function iperf_test {
|
|
|
|
URL=$1
|
|
|
|
|
|
|
|
I=0
|
|
|
|
while [ $I -lt 10 ]
|
|
|
|
do
|
|
|
|
IPERF_RUN_SEND="$($IPERF_PATH/iperf3 -c $URL -P 8)"
|
|
|
|
if [[ "$IPERF_RUN_SEND" != *"error"* ]]; then
|
|
|
|
I=10
|
|
|
|
#echo "iperf Send Success!!" # debug
|
|
|
|
else
|
|
|
|
I=$(( $I + 1 ))
|
|
|
|
#echo "iperf Send Failure..." # debug
|
|
|
|
sleep 3
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
J=0
|
|
|
|
while [ $J -lt 10 ]
|
|
|
|
do
|
|
|
|
IPERF_RUN_RECV="$($IPERF_PATH/iperf3 -c $URL -P 8 -R)"
|
|
|
|
if [[ "$IPERF_RUN_SEND" != *"error"* ]]; then
|
|
|
|
J=10
|
|
|
|
#echo "iperf Recv Success!!" # debug
|
|
|
|
else
|
|
|
|
J=$(( $I + 1 ))
|
|
|
|
#echo "iperf Recv Failure..." # debug
|
|
|
|
sleep 3
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
IPERF_SENDRESULT="$(echo "${IPERF_RUN_SEND}" | grep SUM | grep receiver)"
|
|
|
|
IPERF_RECVRESULT="$(echo "${IPERF_RUN_RECV}" | grep SUM | grep receiver)"
|
|
|
|
}
|
|
|
|
|
2019-10-03 10:25:58 +07:00
|
|
|
IPERF_LOCS=( \
|
|
|
|
"bouygues.iperf.fr" "Bouygues Telecom" "Paris, FR" \
|
|
|
|
"ping.online.net" "Online.net" "Paris, FR" \
|
|
|
|
)
|
|
|
|
IPERF_LOCS_NUM=${#IPERF_LOCS[@]}
|
|
|
|
IPERF_LOCS_NUM=$((IPERF_LOCS_NUM / 3))
|
|
|
|
|
|
|
|
for (( i = 0; i < IPERF_LOCS_NUM; i++ )); do
|
|
|
|
iperf_test ${IPERF_LOCS[i*3]}
|
|
|
|
echo "${IPERF_LOCS[i*3+1]} in ${IPERF_LOCS[i*3+2]} send result: $IPERF_SENDRESULT"
|
|
|
|
echo "${IPERF_LOCS[i*3+1]} in ${IPERF_LOCS[i*3+2]} recv result: $IPERF_RECVRESULT"
|
2019-10-03 09:51:36 +07:00
|
|
|
done
|
2019-10-03 08:48:33 +07:00
|
|
|
|
|
|
|
# iperf debug
|
|
|
|
#echo -e "#######################"
|
|
|
|
#echo -e "${IPERF_RUN_SEND}"
|
|
|
|
#echo -e "${IPERF_RUN_RECV}"
|
|
|
|
|
|
|
|
rm -rf /tmp/$DATE
|