Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # medidor de ping
- # https://espanol.cox.com/residential/internet/guides/gaming-performance/ping-testing.html}
- # Menos de 50 ms 'bueno'
- # Menos de 100 ms 'regular'
- # Menos de 150 ms 'malo'
- # Mayor a 150 ms 'sin conexion'
- # 1 True
- # 0 False
- host=$1
- while :; do
- clear
- ping=$(ping -c 1 $host | grep "64 bytes from" | cut -d "=" -f 4 | cut -d " " -f 1)
- # si el valor es entero pasarlo a decimal.
- [[ "$ping" =~ .*$ ]] || ping=${ping}.0
- if [ $(awk 'BEGIN { if ('$ping' > 100.0) print 1; else print 0 }') -eq 1 ] &&
- [ $(awk 'BEGIN { if ('$ping' <= 150.0) print 1; else print 0 }') -eq 1 ]; then
- echo "malo"
- elif [ $(awk 'BEGIN { if ('$ping' <= 50.0) print 1; else print 0 }') -eq 1 ]; then
- echo "bueno"
- elif [ $(awk 'BEGIN { if ('$ping' > 150.0) print 1; else print 0 }') -eq 1 ]; then
- echo "sin conexion"
- else
- echo "regular"
- fi
- sleep 0.5
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement