-
-
Save mbuckbee/79b2e76bd9271bea38487defd8a9138b 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
require 'csv' | |
require 'resolv' | |
csv_list = CSV.read("top500.csv") | |
domains = [] | |
csv_list.each do |line| | |
domains << line[1].gsub("/","") | |
end | |
ttls = [] | |
domains.each do |domain| | |
#puts domain | |
begin | |
dns = Resolv::DNS.new.getresource(domain, Resolv::DNS::Resource::IN::A) | |
#puts dns.ttl | |
ttls << dns.ttl | |
rescue | |
# puts "Fail: #{domain}" | |
end | |
end | |
lowest = ttls.min | |
highest = ttls.max | |
total = ttls.inject(:+) | |
len = ttls.length | |
average = total.to_f / len # to_f so we don't get an integer result | |
sorted = ttls.sort | |
median = len % 2 == 1 ? sorted[len/2] : (sorted[len/2 - 1] + sorted[len/2]).to_f / 2 | |
puts "\n \n \n" | |
puts "Lowest: " + lowest.to_s | |
puts "Highest: " + highest.to_s | |
puts "Domains Resolved: " + len.to_s | |
puts "Average: " + average.to_s | |
puts "Median: " + median.to_s | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment