Created
November 2, 2012 13:57
-
-
Save daniel-marschner/4001503 to your computer and use it in GitHub Desktop.
Revisions
-
Daniel Marschner revised this gist
Nov 2, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ # Fetches the first argument passed to the script, if no is given # it raises and error with this simple custom message. unless @domain = ARGV.first raise "You need to pass in a domain like www.6wunderkinder.com" end puts "[#{DateTime.now}] Started the DNS check for #{@domain}..." -
Daniel Marschner revised this gist
Nov 2, 2012 . 1 changed file with 10 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,25 +1,25 @@ require 'net/http' require 'date' # Fetches the first argument passed to the script, if no is given # it raises and error with this simple custom message. unless @domain = ARGV.first raise "You need to pass in a domain name like www.6wunderkinder.com" end puts "[#{DateTime.now}] Started the DNS check for #{@domain}..." # Sends a simple GET request to the given domain and checks # if the response was 200 OK. def do_request uri = URI("http://#{@domain}") response = Net::HTTP.get_response(uri) response.is_a?(Net::HTTPOK) end # Puts a NotFound message and sleeps for 60 seconds as long as the # request is not a 200 OK. If there is a 200 OK coming back it puts # the success message and the script terminates. begin while do_request == false puts "[#{DateTime.now}] NotFound: #{@domain}..." @@ -29,10 +29,10 @@ def do_request puts "[#{DateTime.now}] Success: #{@domain} is up and running!" puts "[#{DateTime.now}] Done." # If something went wrong, any error occurs the script terminates # with a error message. rescue => e puts "[#{DateTime.now}] Error: We couldn't reach #{@domain}!" puts "[#{DateTime.now}] Error: #{e.message}" puts "[#{DateTime.now}] Canceled." end -
Daniel Marschner created this gist
Nov 2, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ require 'net/http' require 'date' # Fetches the first argument passed to the script, if no is given it raises and error # with this simple custom message. unless @domain = ARGV.first raise "You need to pass in a domain name like www.6wunderkinder.com" end puts "[#{DateTime.now}] Started the DNS check for #{@domain}..." # Sends a simple GET request to the given domain and checks if the response was # 200 OK. def do_request uri = URI("http://#{@domain}") response = Net::HTTP.get_response(uri) response.is_a?(Net::HTTPOK) end # Puts a NotFound message and sleeps for 60 seconds as long as the request is not a # 200 OK. If there is a 200 OK coming back it puts the success message and the script # terminates. begin while do_request == false puts "[#{DateTime.now}] NotFound: #{@domain}..." sleep 60 end puts "[#{DateTime.now}] Success: #{@domain} is up and running!" puts "[#{DateTime.now}] Done." # If something went wrong, any error occurs the script terminates with a error # message. rescue => e puts "[#{DateTime.now}] Error: We couldn't reach #{@domain}, something went wrong!" puts "[#{DateTime.now}] Error: #{e.message}" puts "[#{DateTime.now}] Canceled." end