Skip to content

Instantly share code, notes, and snippets.

@apinstein
Last active June 1, 2020 11:07
Show Gist options
  • Save apinstein/c5b0f7b0f498caea4ed0 to your computer and use it in GitHub Desktop.
Save apinstein/c5b0f7b0f498caea4ed0 to your computer and use it in GitHub Desktop.

Revisions

  1. apinstein revised this gist Dec 11, 2015. No changes.
  2. apinstein created this gist Dec 11, 2015.
    23 changes: 23 additions & 0 deletions test-wifi.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    #!/bin/zsh

    # configure curl output format
    echo '%{url_effective},%{time_namelookup},%{time_connect},%{time_appconnect},%{time_pretransfer},%{time_redirect},%{time_starttransfer},%{time_total}' > curltime.format

    # configure postgres
    echo "create table wifi_data (ssid text,url_effective text,time_namelookup numeric(9,5),time_connect numeric(9,5),time_appconnect numeric(9,5),time_pretransfer numeric(9,5),time_redirect numeric(9,5),time_starttransfer numeric(9,5),time_total numeric(9,5));"
    echo ""
    echo "\\\\copy wifi_data from './wifi-data.csv' DELIMITER ',' CSV HEADER"
    echo "select ssid, count(*), avg(time_total), stddev(time_total), min(time_total), max(time_total) from wifi_data group by ssid having count(*) > 5;"

    echo ""
    echo ""

    # setup csv
    echo 'ssid,url_effective,time_namelookup,time_connect,time_appconnect,time_pretransfer,time_redirect,time_starttransfer,time_total' > './wifi-data.csv'
    while true; do
    echo ` /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | pcregrep -o1 '\bSSID: *(.*) *'` \
    , \
    `curl -w "@curltime.format" --silent -o /dev/null http://www.google.com` \
    | tee -a './wifi-data.csv'
    sleep 1
    done;