Created
October 21, 2018 06:17
-
-
Save ruanltbg/922719f34273a9232bb015990fe77ccf 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 "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