Created
June 7, 2013 23:00
-
-
Save csokol/5733000 to your computer and use it in GitHub Desktop.
script to check if a server is up, requires httparty gem and ruby compiled with openssl, to install deps: rvm install ruby-1.9.3-p376
rvm package install openssl
gem install httparty
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/smtp' | |
require 'httparty' | |
server_up = true | |
begin | |
response = HTTParty.get("http://metricminer.org.br/") | |
rescue | |
server_up = false | |
end | |
server_up = false if not response.nil? and response.code != 200 | |
exit if server_up | |
smtp = Net::SMTP.new 'smtp.gmail.com', 587 | |
smtp.enable_starttls | |
msg = "Subject: MetricMiner down!\n\nMetricminer is down!" | |
smtp.start('gmail.com', 'metricminer', password, :login) do | |
smtp.send_message(msg, 'metricminer@gmail.com', 'email@gmail.com', 'email2@gmail.com') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
script to check if a server is up, requires httparty gem and ruby compiled with openssl, to install deps: