Created
May 31, 2015 23:12
-
-
Save leonardofaria/8e3672e85b7c4b20397b to your computer and use it in GitHub Desktop.
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
gem 'mechanize', '2.7.2' | |
require 'mechanize' | |
require 'pony' | |
def sendmail(to, subject, body) | |
Pony.mail({ | |
:to => to, | |
:via => :smtp, | |
:subject => subject, | |
:body => body, | |
:charset => 'UTF-8', | |
:via_options => { | |
:address => 'smtp.sendgrid.net', | |
:port => '587', | |
:domain => 'heroku.com', | |
:user_name => ENV['SENDGRID_USERNAME'], | |
:password => ENV['SENDGRID_PASSWORD'], | |
:authentication => :plain, | |
:enable_starttls_auto => true | |
} | |
}) | |
end | |
mechanize = Mechanize.new{|a| a.ssl_version, a.verify_mode = 'SSLv3', OpenSSL::SSL::VERIFY_NONE} | |
page = mechanize.get('https://www.yourwebsite.com/mytesturl') | |
content = "" | |
if page.body.include?('refused') | |
content = 'Error: Connection Refused' | |
end | |
if content | |
puts content | |
sendmail("email@domain.com", "Monitor", content) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment