Created
October 1, 2016 11:27
-
-
Save t2psyto/830a84908f2a85bdabb7feabff49976e to your computer and use it in GitHub Desktop.
measuring ping & download speed, + post to server.
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
#!/bin/sh | |
SPEEDTEST_HOST=url01.ookla-speedtest.aseinet.com | |
GOOGLE_SPLEADSHEET_DOGET_URL=https://script.google.com/macros/s/this-is-example-url-tincbrabrabrabrabrabrabrabrabrabrab/exec | |
#timestamp "YYYY-MM-DD hh:mm:ss" | |
TIMESTAMP=`date '+%F %T'` | |
# ping RTT (ms) | |
PING=$(ping -c 4 -q ${TARGET_HOST} | awk -F '[/ ]' 'END {print $7}') | |
# download speed (bps) | |
SPEED=$(for i in `seq 4`; do \ | |
curl --connect-timeout 60 --max-time 120 -s -o /dev/null http://${SPEEDTEST_HOST}/speedtest/random500x500.jpg \ | |
-w '%{speed_download}'; \ | |
done | awk '{x+=$1} END {print (x*8)/(1024*NR)}') | |
# do post to server | |
curl --connect-timeout 60 --max-time 120 -s -L ${GOOGLE_SPLEADSHEET_DOGET_URL} \ | |
-d "timestamp=${TIMESTAMP}" -d "ping=${PING}" -d "speed=${SPEED}" -d "host=${SPEEDTEST_HOST}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
easyapi.gs と一緒に使う
https://gist.github.com/t2psyto/1cb53e083339f0402be5eea65bbc621c