Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env ruby
# Speedtest cli to wrapper
# based on
# More: (german)
# Original:
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("\"","\\\"")}\" \{secret_key} > /dev/null`"/tmp/speedtest.log", "a") { |file| file.puts("#{}\
- 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
You can’t perform that action at this time.