35 lines
773 B
Plaintext
35 lines
773 B
Plaintext
|
#! /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
|
||
|
declare -i alltimelowest=0
|
||
|
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
|
||
|
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
|
||
|
|