Skip to content

Instantly share code, notes, and snippets.

@Arie
Created October 10, 2017 09:38
Show Gist options
  • Save Arie/4b9f66a418df319b5820d3bca62261e3 to your computer and use it in GitHub Desktop.
Save Arie/4b9f66a418df319b5820d3bca62261e3 to your computer and use it in GitHub Desktop.
require 'csv'
last_result = `tail -n1 /usr/share/cacti/site/scripts/speedtest.csv`
def bits_to_mbit(bits)
bits / 1024.0 / 1024.0
end
CSV.parse(last_result) do |row|
@ping = row[5].to_f
@down_speed = bits_to_mbit(row[6].to_f)
@up_speed = bits_to_mbit(row[7].to_f)
end
puts "down:#{@down_speed.round(1)} up:#{@up_speed.round(1)} ping:#{@ping.round(1)}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment