Last active
May 27, 2020 08:53
-
-
Save sethiele/e19ca737dbd96887f5a1 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 ruby | |
# Speedtest cli to ifttt.com wrapper | |
# based on https://github.com/HenrikBengtsson/speedtest-cli-extras | |
# More: https://www.iamyourfather.de/dsl-speedtest-mit-dem-raspberry-pi (german) | |
# Original: http://makezine.com/projects/send-ticket-isp-when-your-internet-drops/ | |
require 'json' | |
secret_key = "XXXXXXXXXXX" | |
speedtest = `/usr/local/bin/speedtest-cli --share` | |
upload = speedtest.scan(/Upload: ([0-9\.]{3,5})/)[0][0] | |
download = speedtest.scan(/Download: ([0-9\.]{3,5})/)[0][0] | |
ping = speedtest.scan(/]: ([0-9\.]{3,6})/)[0][0] | |
share = speedtest.scan(/Share results: (.*)/)[0][0] | |
json = {value1: ping, value2: download, value3: upload} | |
`curl -X POST -H \"Content-Type: application/json\" \ | |
-d \"#{JSON[json].to_s.gsub("\"","\\\"")}\" \ | |
https://maker.ifttt.com/trigger/speedtest/with/key/#{secret_key} > /dev/null` | |
File.open("/tmp/speedtest.log", "a") { |file| file.puts("#{Time.now}\ | |
- Ping: #{ping}\ | |
- Download: #{download}\ | |
- Upload: #{upload}\ | |
- Share: #{share}") } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Danke für das Script! Die Anleitung auf Deiner Seite https://www.iamyourfather.de/dsl-speedtest-mit-dem-raspberry-pi funktioniert im Prinzip. Ich habe das IFTTT-Rezept noch ein wenig angepasst: wenn man für das Google Sheet als Formatted row das hier eingibt, dann bekommt man eine echte Zeitachse im Graphen:
=TIMEVALUE(SUBSTITUTE("{{OccurredAt}}"," at ", " ")) + DATEVALUE(SUBSTITUTE("{{OccurredAt}}"," at ", " ")) ||| {{Value1}} |||{{Value2}} ||| {{Value3}}
Der Tipp kommt von https://gist.github.com/oscarmorrison/bf14dab89854238d4cca