Skip to content

Instantly share code, notes, and snippets.

@deadc
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save deadc/3233df6f5afba5153598 to your computer and use it in GitHub Desktop.

Select an option

Save deadc/3233df6f5afba5153598 to your computer and use it in GitHub Desktop.

Revisions

  1. deadc revised this gist Jun 10, 2014. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion twitch_latency.sh
    Original file line number Diff line number Diff line change
    @@ -7,10 +7,12 @@ 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)
    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%%:*}
    }
  2. deadc created this gist Jun 10, 2014.
    20 changes: 20 additions & 0 deletions twitch_latency.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #!/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"