2021-02-28 01:11:48 -06:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
declare -i samples=100
|
|
|
|
declare -a servers=('1.1.1.1' '8.8.8.8')
|
|
|
|
declare -i highestloss=0
|
|
|
|
|
|
|
|
declare -i alltimehighest=0
|
2021-02-28 01:23:33 -06:00
|
|
|
declare -i alltimelowest=100
|
2021-02-28 01:11:48 -06:00
|
|
|
declare -i iterations=1
|
|
|
|
|
|
|
|
while :; do
|
|
|
|
highestloss=0
|
|
|
|
for server in "${servers[@]}"; do
|
|
|
|
stats="$(ping "$server" -c "$samples" | tail -n 2 | head -n 1)"
|
|
|
|
losspercent="$(echo "$stats" | cut -f6 -d ' ')"
|
|
|
|
loss="${losspercent%\%}"
|
|
|
|
[ -z "$loss" ] && continue
|
|
|
|
if (( loss > highestloss )); then
|
|
|
|
highestloss="$loss"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
color="\e[34m"
|
|
|
|
if (( highestloss > 0 )); then
|
|
|
|
color="\e[31m"
|
|
|
|
fi
|
2021-02-28 01:23:33 -06:00
|
|
|
if (( highestloss > alltimehighest )); then
|
|
|
|
alltimehighest="$highestloss"
|
|
|
|
fi
|
|
|
|
if (( highestloss < alltimelowest )); then
|
|
|
|
alltimelowest="$highestloss"
|
|
|
|
fi
|
2021-02-28 01:11:48 -06:00
|
|
|
printf "\\rCurrent loss: $color%-3.3s\e[0m - \e[33m%-4.4s \e[34m%-4.4s \e[0m%-4.4s" \
|
|
|
|
"$highestloss" \
|
|
|
|
"$alltimehighest" \
|
|
|
|
"$alltimelowest" \
|
|
|
|
"$iterations"
|
|
|
|
iterations="$(( iterations + 1 ))"
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|