Skip to content

Instantly share code, notes, and snippets.

@ross-nordstrom
Last active August 29, 2015 14:07
Show Gist options
  • Save ross-nordstrom/daaf8bfe9b1ca453c1ea to your computer and use it in GitHub Desktop.
Save ross-nordstrom/daaf8bfe9b1ca453c1ea to your computer and use it in GitHub Desktop.
Get ping, download, and upload speeds using Speedtest.net. Requires speedtest cli (https://github.com/sivel/speedtest-cli)
#!/usr/bin/env ruby
require 'json'
speedtest = `speedtest-cli --simple`
updown = speedtest.split("\n")
bandwidthData = {
:Ping => updown[0].split(' ')[1].to_f/1000,
:Download => updown[1].split(' ')[1].to_f,
:Upload => updown[2].split(' ')[1].to_f
}
puts bandwidthData.to_json.gsub(/"/, "'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment