Skip to content

Instantly share code, notes, and snippets.

@ruanltbg
Created October 21, 2018 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruanltbg/922719f34273a9232bb015990fe77ccf to your computer and use it in GitHub Desktop.
Save ruanltbg/922719f34273a9232bb015990fe77ccf to your computer and use it in GitHub Desktop.
require "net/http"
require "uri"
not_in_trace = true
def checker
uri = URI.parse("http://www.tudogostoso.com.br/")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
print_trace if response.code == "504"
puts "Date: #{Time.now.strftime("%d/%m/%Y %H:%M:%S")} - #{response.code}"
end
def print_trace
not_in_trace = false
puts "#######################"
dig = "ping -c2 www.tudogostoso.com.br"
traceroute = "traceroute www.tudogostoso.com.br"
curl = "curl -H 'Pragma: akamai-x-cache-on' -H 'Pragma: akamai-x-check-cacheable' -I http://www.tudogostoso.com.br"
notification = "osascript -e 'display notification \"Status: 504\" with title \"TDG Ping Error\"'"
system( notification )
system( dig )
puts "##### CURL ####"
system( curl )
puts "#######################"
puts "##### TRACE ####"
system( traceroute )
puts "#######################"
not_in_trace = true
end
while true do
checker if not_in_trace
sleep(1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment