Last active
August 29, 2015 14:02
-
-
Save deadc/3233df6f5afba5153598 to your computer and use it in GitHub Desktop.
Script to check best Twitch server available
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# $ Script to check best Twitch server available. | |
# Needs hping / w3m | |
SERVERS="http://bashtech.net/twitch/ingest.php" | |
function _best_twlt | |
{ | |
for SERVER in $(w3m -dump ${SERVERS}|grep RTMP|grep -oE 'live-.*.twitch.tv'); do | |
LATENCY=$(sudo -i hping -q -c 2 -S -p 80 ${SERVER} 2>&1 | grep -oE '^round-trip.*' | awk '{print $4}' | cut -d '/' -f 2) | |
SRVLT="${LATENCY}:${SERVER}\n${SRVLT}" | |
done | |
BESTLT=$(echo -e ${SRVLT}|sort|awk NF|head -n 1) | |
BESTSV=${BESTLT##*:} | |
BESTLT=${BESTLT%%:*} | |
} | |
_best_twlt | |
echo "The best server of Twitch right now is ${BESTSV} with ${BESTLT} ms" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment