Skip to content

Instantly share code, notes, and snippets.

@miticojo
Last active September 22, 2019 13:31
Show Gist options
  • Save miticojo/5feb93b5b19a69e53f3de6da886636ab to your computer and use it in GitHub Desktop.
Save miticojo/5feb93b5b19a69e53f3de6da886636ab to your computer and use it in GitHub Desktop.

Revisions

  1. miticojo revised this gist Sep 22, 2019. 1 changed file with 14 additions and 3 deletions.
    17 changes: 14 additions & 3 deletions long-ping-apis.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,9 @@
    #!/bin/bash

    APIURL=https://speech.googleapis.com
    REMOTEIP=$(curl -s ipinfo.io/ip)
    REMOTEASN=$(curl -s ipinfo.io/org | cut -d' ' -f1)
    RESULTFILE="google-ping-api-results-$(date +%s).csv"

    ## Script start time
    START=$(date +%s)
    @@ -10,13 +13,18 @@

    ## Total running time
    UPTIME=$(($(date +%s) - $START))

    echo "timestamp,time_namelookup,time_connect,time_appconnect,time_pretransfer,time_redirect,time_starttransfer,time_total"
    echo "=========================================="
    echo "Starting 24h connection test to $APIURL..."
    echo "Results are written into $RESULTFILE"
    echo "=========================================="
    sleep 2
    (
    echo "timestamp,remote_ip,remote_asn,time_namelookup,time_connect,time_appconnect,time_pretransfer,time_redirect,time_starttransfer,time_total"
    while [[ $UPTIME -le $DURRATION ]]; do

    curl -s -o /dev/null \
    -w "%{time_namelookup},%{time_connect},%{time_appconnect},%{time_pretransfer},%{time_redirect},%{time_starttransfer},%{time_total}\n" \
    $APIURL | xargs -L 1 echo "$(date +'%s'),$1"
    $APIURL | xargs -L 1 echo "$(date +'%s'),$REMOTEIP,$REMOTEASN,$1"

    ## Sleep for a bit
    sleep 2
    @@ -25,3 +33,6 @@
    UPTIME=$(($(date +%s) - $START))

    done
    ) | tee $RESULTFILE
    echo "=========================================="
    echo "Connection test completed with success. Please send back the results file $RESULTFILE for analisys."
  2. miticojo revised this gist Sep 21, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion long-ping-apis.sh
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@
    UPTIME=$(($(date +%s) - $START))

    echo "timestamp,time_namelookup,time_connect,time_appconnect,time_pretransfer,time_redirect,time_starttransfer,time_total"
    while [[ $UPTIME < $DURRATION ]]; do
    while [[ $UPTIME -le $DURRATION ]]; do

    curl -s -o /dev/null \
    -w "%{time_namelookup},%{time_connect},%{time_appconnect},%{time_pretransfer},%{time_redirect},%{time_starttransfer},%{time_total}\n" \
  3. miticojo revised this gist Sep 21, 2019. 1 changed file with 21 additions and 20 deletions.
    41 changes: 21 additions & 20 deletions long-ping-apis.sh
    Original file line number Diff line number Diff line change
    @@ -1,26 +1,27 @@
    #!/bin/bash
    #!/bin/bash

    APIURL=https://speech.googleapis.com
    APIURL=https://speech.googleapis.com

    ## Script start time
    START=$(date +%s)
    ## Script start time
    START=$(date +%s)

    ## Total run time
    DURRATION=$((60 * 60 * 24))
    ## Total run time
    DURRATION=$((60 * 60 * 24))

    ## Total running time
    UPTIME=$(($(date +%s) - $START))

    while [[ $UPTIME < $DURRATION ]]; do

    curl -s -o /dev/null \
    -w "%{time_namelookup},%{time_connect},%{time_appconnect},%{time_pretransfer},%{time_redirect},%{time_starttransfer},%{time_total}\n" \
    $APIURL | xargs -L 1 echo "$(date +'%s'),$1"

    ## Sleep for a bit
    sleep 2

    ## Update running time
    ## Total running time
    UPTIME=$(($(date +%s) - $START))

    echo "timestamp,time_namelookup,time_connect,time_appconnect,time_pretransfer,time_redirect,time_starttransfer,time_total"
    while [[ $UPTIME < $DURRATION ]]; do

    curl -s -o /dev/null \
    -w "%{time_namelookup},%{time_connect},%{time_appconnect},%{time_pretransfer},%{time_redirect},%{time_starttransfer},%{time_total}\n" \
    $APIURL | xargs -L 1 echo "$(date +'%s'),$1"

    ## Sleep for a bit
    sleep 2

    ## Update running time
    UPTIME=$(($(date +%s) - $START))

    done
    done
  4. miticojo created this gist Sep 20, 2019.
    26 changes: 26 additions & 0 deletions long-ping-apis.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    #!/bin/bash

    APIURL=https://speech.googleapis.com

    ## Script start time
    START=$(date +%s)

    ## Total run time
    DURRATION=$((60 * 60 * 24))

    ## Total running time
    UPTIME=$(($(date +%s) - $START))

    while [[ $UPTIME < $DURRATION ]]; do

    curl -s -o /dev/null \
    -w "%{time_namelookup},%{time_connect},%{time_appconnect},%{time_pretransfer},%{time_redirect},%{time_starttransfer},%{time_total}\n" \
    $APIURL | xargs -L 1 echo "$(date +'%s'),$1"

    ## Sleep for a bit
    sleep 2

    ## Update running time
    UPTIME=$(($(date +%s) - $START))

    done