Outpost is me, scratching my own itch. For a while now, freelancing or working
for others, I work with pretty much all the stack in web development: from front-end
development with HTML and CSS up to the system administration.
And sometimes, I screw up. Sometimes, stuff go wrong. Maybe that Sphinx
isn’t getting indexed or even running after an unsuccessful deploy. Maybe that
background job isn’t being run, and I forget to verify it.
I know there are excellent tools that already solve this problem. But I wanted an
easy way I would be able to code my own monitoring rules, using one of the
languages I like the most. And also, the fantastic Aaron Patterson (or
tenderlove), one of the most prominent faces of the Ruby community once told in
a Q&A at RMU: it should be fun!
And thus the Outpost idea was born. Outpost is a framework so I can easily
implement Ruby code that query the current state of any service I want. I can
also write code that can go into the database and do a SELECT on a table (a
jobs table, for example) to check if everything’s fine.
What is Outpost?
Outpost is basically a DSL where you can describe rules to monitor your
service, application, server, whatever. Below is a very simple example:
require 'outpost'
require 'outpost/scouts'
class MyWebPageOutpost "web page" do
options :host => 'localhost', :port => 3000
report :up, :response_code => 200
report :down, :response_body => {:match => /Ops/}
end
end
In this example, we are monitoring (using what I’ve called ‘Scouts’) HTTP
communication to localhost:3000
. It will report that the system is
up if the response code is 200 (HTTP OK) and report that it is down if the
response body contains the word “Ops”, by matching a Regular Expression to it.
There is still a lot of work to be done, but I feel it is ready for a very first
release. There are only two Scouts today: HTTP and Ping, but it’s so
easy to write new ones that I will be releasing a few more in the next
days.
Also, there are only three expectation matchers: response time, response body
and response code. I believe they are able to cover most of the cases, but it is also
very easy to write new expectations.
Below is another example of an Outpost, based on the integration tests:
require 'outpost'
require 'outpost/scouts'
class ExamplePingAndHttp 'master http server' do
options :host => 'localhost', :port => 9595, :path => '/'
report :up, :response_body => {:match => /Up/}
end
using Outpost::Scouts::Ping => 'load balancer' do
options :host => 'localhost'
report :up, :response_time => {:less_than => 500}
end
end
For more details, please check the project’s README, on GitHub.
The future
My plans for Outpost are: SSH support, so you can connect to servers that do
not expose their services to the outer world, a very simple web dashboard to show
the results, better error reporting (for now you can only know which Scout
failed, but not why), a script that automatically generates Outposts for Rails
apps, and the list goes on!
Crazy idea: wouldn’t it be nice to have a script that reads Outposts and
tells if a machine is ready to be in production? TDD for machines? Woot!
Thanks
This project was my personal project for RMU (Ruby Mendicant University) and
so I would like to thank all the people involved for the amazing experience and
reviews on the project. Also thanks to my friends for listening me nagging
about this project for a while. Finally, thanks to Tomás D’Stefano, who
did some work on my previous attempt to write Outpost, your work won’t be
thrown away.
Closing
Please share your thoughts about this project. I would love to know your opinion!
Here is a Rails engine for monitoring: https://github.com/justinko/diagnostics