Last active
March 19, 2020 00:22
-
-
Save scy/452d354e547333600e755e4f14696140 to your computer and use it in GitHub Desktop.
Log Speedtest.net results to IoTPlotter
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 | |
# Requires the (official) Speedtest CLI app available at ./speedtest | |
# Get it at <https://www.speedtest.net/apps/cli> | |
# Usage: speedlog.sh feed_id api_key | |
# Get the two arguments from your IoTPlotter.com feed. | |
# Currently, a single server (ID 1746) is hardcoded. | |
# I'll make this configurable soon™. | |
now="$(date +%s)" | |
feed="$1" | |
key="$2" | |
printf '%d\t%s\n' "$now" "$(./speedtest -s 1746 -f tsv)" \ | |
| tee -a './speedlog.log' \ | |
| awk \ | |
-F '\t' \ | |
'{ print $1 ",latency," $4; print $1 ",jitter," $5; print $1 ",packet_loss," $6; print $1 ",downstream," $7 * 8; print $1 ",upstream," $8 * 8; print $1 ",downloaded," $9; print $1 ",uploaded," $10 }' \ | |
| curl \ | |
--data-binary @- \ | |
-H "api-key: $key" \ | |
"https://iotplotter.com/api/v2/feed/${feed}.csv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment