Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 

README.md

check_site_status.rb

This little script checks whether or not a website can be reached. It then logs the result to a text file and, if provided, emails an alert when the site is down.

Usage

$ cd .../check_site_status
$ bundle install
$ ruby lib/check_site_status.rb <URL> [email_to] [alternate_log_directory]

Cron

Call this script from Cron to set up a site monitor so you can always know when your site isn't up! In order to call Ruby files from your crontab, you must load an environment containing the Ruby runtime. Here's an example that runs every ten minutes, just replace my BASH_ENV with the path to load your environment.

SHELL=/bin/bash
BASH_ENV = $HOME/.bash_profile

*/10 * * * * $HOME/code/scripts/check_site_status.rb http://brandonrubin.me steelsouls@gmail.com

Email

In order for email to work, you must set up a local mail server and add a $USER_EMAIL environment variable. I run this with Ubuntu 12.04 and 13.04, and my favorite mail server is Postfix. All you really need to get working is outgoing mail, which I've found to be easier than incoming, as you don't have to open any ports, set up spam filtering, or worry about what type of mailbox you have.

Dependencies

  • Faraday gem
  • Pony gem

These can be installed manually or by issuing 'bundle install' inside the script's directory.

License

Copyright (C) 2013 Brandon Rubin (steelsouls), MIT License

About

Check a website for a response, log the result, and send out an email if the site is down.

Resources

License

Releases

No releases published

Packages

No packages published

Languages