Ruby way of alerting on server issues.
Switch branches/tags
Nothing to show


= AlertMachine

Get notifications if bad things happen to your server. You can easily make sure
all processes are running, ports are open. You can also add checks for bad events
that get run once every few minutes and get error reports to your email.

== Usage
0. Install:

gem install alert_machine

1. Defining a Watcher class:

class MyWatcher < AlertMachine::Watcher

    # Example 1: Make sure port 80 is running on server1 and server2.
    watch_process(["", ""], :port => 80)

    # Example 2: Make sure the two thin servers are running in server1.
    # Check if the two ports are open, and check if the two pid files are present
    # and pointing to valid processes.
    watch_process("", :port => [3000, 3001], :pid_file =>
        ["/tmp/", "/tmp/"])

    # Example 3: We can also make sure there are no new crashes.
    watch(:retries => 0) do
        new_crashes = Crash.where(unread: false).all
        assert new_crashes.empty?, <<MAIL
        #{new_crashes.length} new crashes found.
        #{ new_crashes.collect {|c| c.print }.join("\n") }
    # The above code asserts that new_crashes is empty. If it's not empty
    # an alert is triggerred with the message contents being the string
    # that follows the assert.

2. Running the watcher class:

File: my_watcher_runner.rb
require 'alert_machine'

# The below line safely loads the rails environment sending out alerts
# incase things are broken.

# Require your alert files.
require "offline/alerts/my_watcher1.rb"
require "offline/alerts/my_watcher2.rb"

# Run the machine.

== Configuration

If you want to change the default settings, you can call:


before the ``

You can also easily pass diff config files for development and production, if
you are using rails.

A list of all config options are available at AlertMachine::Watcher#watch and