Skip to content

Instantly share code, notes, and snippets.

@rubenbruno89
Created December 19, 2017 03:34
Show Gist options
  • Save rubenbruno89/0f956b0c5c5d707857c9173b8d1d9f69 to your computer and use it in GitHub Desktop.
Save rubenbruno89/0f956b0c5c5d707857c9173b8d1d9f69 to your computer and use it in GitHub Desktop.
Velocidade da internet
#!/bin/bash
# 09 DE NOVEMBRO DE 2017
#UNIVERSIDADE CATOLICA DE BRASILIA
#ALUNO: RUBEN BRUNO CAVALCANTE DE MENEZES
#PROGRAMAÇÃO PARA REDES
#velocidade.sh: exibe a utilizacao do dispositivo de rede
interface=$1
intervalo=1
#Validando interface
if ! ip l l dev $interface &> /dev/null; then
echo "Interface '$interface' não existe"
exit
fi
get_speed () {
echo $(ifconfig $interface | awk -F: '/RX bytes/ { print $2+0 " " $3+0 } ')
}
print_speed () {
if [ $1 -gt 1000000000 ] ; then
echo "$(echo "scale=3; $1 / 1000000000" | bc) Gbps"
elif [ $1 -gt 1000000 ]; then
echo "$(echo "scale=3; $1 / 1000000" | bc) Mbps"
elif [ $1 -gt 1000 ]; then
echo "$(echo "scale=3; $1 / 1000" | bc) Kbps"
else
echo "$1 bps"
fi
}
clear
echo "Calculando..."
speed0=($(get_speed))
while true; do
sleep $intervalo
speed1=($(get_speed))
vr=$(( (${speed1[0]} - ${speed0[0]}) * 8 / $intervalo))
vt=$(( (${speed1[1]} - ${speed0[1]}) * 8 / $intervalo))
clear
echo "===Uso da interface $interface ==="
echo "Velocidade download: $(print_speed $vr)"
echo "Velocidade upload..: $(print_speed $vt)"
speed0=(${speed1[@]})
done
@Julfikar3
Copy link

Julfikar3 commented Oct 10, 2020

your m3u file link is dead only 2 link live please update link with being sport channel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment