Last active
August 29, 2015 14:24
-
-
Save jab416171/510eb425bbb3d8fb3acd to your computer and use it in GitHub Desktop.
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 python | |
import gspread | |
import sys | |
import json | |
from oauth2client.client import SignedJwtAssertionCredentials | |
timestamp = sys.argv[1] | |
ping = sys.argv[2] | |
up = sys.argv[3] | |
down = sys.argv[4] | |
json_key = json.load(open('/path/to/my-123123123.json')) | |
scope = ['https://spreadsheets.google.com/feeds'] | |
credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope) | |
gc = gspread.authorize(credentials) | |
document = gc.open("Speedtest Results") | |
worksheet = document.worksheet("main") | |
data = (timestamp, ping, up, down) | |
column_count = len(data) | |
if worksheet.col_count < column_count: | |
worksheet.resize(cols=column_count) | |
worksheet.append_row(data) |
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
yum install gcc python-devel openssl-devel libffi-devel | |
pip install gspread | |
pip install oauth2client | |
pip install PyOpenSSL | |
#See here for instructions on the oauth json setup | |
#http://gspread.readthedocs.org/en/latest/oauth2.html |
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 | |
result=$(/bin/speedtest-cli --simple) | |
download=$(echo $result | grep -oP "(?<=Download: )[0-9\.]* .*?/s") | |
upload=$(echo $result | grep -oP "(?<=Upload: )[0-9\.]* .*?/s") | |
ping=$(echo $result | grep -oP "(?<=Ping: )[0-9\.]* .*?ms") | |
addToSpreadsheet "$(date)" "$upload" "$download" "$ping" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment