Skip to content

Instantly share code, notes, and snippets.

@edmore
Created February 12, 2013 18:09
Show Gist options
  • Save edmore/4771919 to your computer and use it in GitHub Desktop.
Save edmore/4771919 to your computer and use it in GitHub Desktop.
Check if site is down from terminal
#! /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