Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A simple way to see what's up, dawg (and what's not.)
Ruby
tag: v0.3.2

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.document
.gitignore
Gemfile
Gemfile.lock
LICENSE
README.rdoc
Rakefile
VERSION

README.rdoc

updawg

A simple way to see what's up, dawg (and what's not.)

Define a list of checks and create a controller that renders the results. Ping the controller with the monitoring tool of your choice, perhaps setting a 503 response when one of the checks fails.

Some options can be set:

UpDawg.configure do |config|
  config.success_text = 'OK'
end

Checks are defined with a simple DSL:

monitor = Updawg.monitor do
  check 'MySQL' do
    # Will raise an exception if the connection is unavailable resulting in a failed check
    ActiveRecord::Base.connection.execute('SELECT 1 FROM DUAL')
  end

  check 'Some threshold' do
    result ||=   error('Threshold exceeded y') if threshold_value > y
    result ||= warning('Threshold exceeded x') if threshold_value > x
	result 
  end

  # alternatively, use warning!/error!/pass! to break out of the check immediately
  check 'Something else' do
    warning!('Something kind of bad happened') if threshold_value > x
    error!  ('Something really bad happened')  if threshold_value > y

	pass!('Everything is just fine')
  end

  # Specify a threshold check for captured purchases in the last 24 hours
  threshold 'Captured Purchases (24 hours)', :warn_under => 10, :error_under => 1 do
    Purchase.captured_at_after(24.hours.ago)
  end

  # Specify a "sweet spot threshold check" to alert when a business metric goes out of normal range
  threshold 'Transactions (24 hours)',
            :warn_under => 100, :error_under => 1,
            :warn_over => 1000, :error_over => 2000 do
    Transaction.created_at_after(24.hours.ago)
  end
end

results = monitor.perform

results.success? => true if no checks error
results.warning? => true if no checks error and at least one has a warning
results.error?   => true if at least one check fails

Render with:

monitor.to_html

<table class="updawg monitor">
  <tr class="check error">
    <td class="name">MySQL</td>
    <td class="message">ActiveRecord::StatementInvalid: Mysql::Error: You have an error in your SQL syntax</td>
    <td class="status">ERROR</td>
  </tr>
  <tr class="check pass">
    <td class="name">Some threshold</td>
    <td class="message"></td>
    <td class="status">PASS</td>
  </tr>
</table>

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Authors

Matt Griffin github.com/betamatt (matt@griffinonline.org)

Copyright

Copyright © 2010 Viximo, Inc. See LICENSE for details.

Something went wrong with that request. Please try again.