Created
February 12, 2013 18:09
-
-
Save edmore/4771919 to your computer and use it in GitHub Desktop.
Check if site is down from terminal
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 characters
#! /usr/bin/env ruby | |
########################################################## | |
# Description - Check whether site is up or down via the | |
# command line. | |
# Author - www.edmoremoyo.com | |
########################################################## | |
require "net/http" | |
require "uri" | |
uri = URI.parse("http://www.isup.me/#{ARGV[0]}") | |
response = Net::HTTP.get_response(uri) | |
if (response.code == '200') | |
data = Net::HTTP.get(uri) | |
is_match = /is up/.match(data) | |
if (is_match) | |
puts "#{ARGV[0]} is UP! Jus you." | |
else | |
puts "#{ARGV[0]} is DOWN dude! Ain't just you." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment