Skip to content

Instantly share code, notes, and snippets.

@leonardofaria
Created May 31, 2015 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonardofaria/8e3672e85b7c4b20397b to your computer and use it in GitHub Desktop.
Save leonardofaria/8e3672e85b7c4b20397b to your computer and use it in GitHub Desktop.
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