Skip to content

Instantly share code, notes, and snippets.

@csokol
Created June 7, 2013 23:00
Show Gist options
  • Save csokol/5733000 to your computer and use it in GitHub Desktop.
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
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
@csokol
Copy link
Author

csokol commented Jun 7, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment