Skip to content

Commit

Permalink
updated doc
Browse files Browse the repository at this point in the history
  • Loading branch information
iloire committed Aug 22, 2012
1 parent 7ac56b2 commit c253d3c
Showing 1 changed file with 84 additions and 21 deletions.
105 changes: 84 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# "watchmen", a service monitor for node.js

- monitor service health in your servers (http, smtp, etc).
- **storages are plugable**. At this time, only redis storage is available.
- **ping types are plugable**. At this time, http (with https) and stmp (tcp connection check) are available.
- monitor service health (outages, uptime, response time warnings, avg. response time, etc) in your servers (`http`, `smtp`, etc).
- use the database of your choice. Data **storages are pluggable**. At this time, only [redis](http://redis.io) storage is available, but it is pretty easy to create and plug your own. There are plans to support `couchdb` and `mongodb` in the short term.
- **ping types are pluggable**. At this time, `http` (includes `https`) and `smtp` (tcp connection check) are available.
- watchmen provides **customizable notifications** if service is down, the response time is over a predefined limit, etc..
- a lot of effort has been made in keeping the code base small, simple and easy to understand and modify.

Using http ping service, for instance, you can check for a) certain status code or b) a certain text in the response stream.
- the code base aims to be small, simple and easy to understand and modify.

There is a <a href="http://letsnode.com/example-of-what-node-is-really-good-at" target="_blank">related blog post about watchmen here</a>.

# Demo

You can see an online demo of how watchmen control panel looks <a href="http://letsnode.com:8084" target="_blank">here</a>.
Check the **web interface** in action <a href="http://letsnode.com:8084" target="_blank">here</a>.

![List of hosts](https://github.com/iloire/WatchMen/raw/1.x/screenshots/list_hosts_v010.png)

Expand All @@ -35,6 +33,8 @@ Make sure you install those dependencies:

You need at least one service for each host. Define the ping service type for each host or service.

Most of the properties can be defined either at host or service level. Service level properties will be prioritized.

```js
//-------------------
//config/hosts.js
Expand Down Expand Up @@ -81,17 +81,39 @@ You need at least one service for each host. Define the ping service type for ea
warning_if_takes_more_than: 700, //miliseconds. alert if request takes more than this
services : [
{
name : 'home'
name : 'my smtp server'
}
]
}
```

### Ping services

#### HTTP

Using http ping service, you can also check for a) certain http status code or b) a certain text in the response stream.

##### Main properties:

- `host.host`
- `host.port`
- `host.ping_service_name` (use 'http', although it is the default value)
- `service.method` (get/post)
- `service.url`
- `service.expected` (expected status code, expected text to be found in response)

#### SMTP
##### Main properties:

- `host.host`
- `host.port`
- `host.ping_service_name` (use 'smtp')

### b) Define Postmark and notifications settings:

```js
//-------------------
//config/general.js
// config/general.js
//-------------------

module.exports.notifications = {
Expand All @@ -108,7 +130,7 @@ module.exports.notifications = {

```js
//-------------------
//config/storage.js
// config/storage.js
//-------------------

module.exports = {
Expand All @@ -131,6 +153,47 @@ module.exports = {
}
}
};
```
### Storage providers

#### Redis
##### Installation and configuration

1. get redis from [redis.io](http://redis.io)
2. launch the server:

```
$ redis-server redis.conf
```
### d) Add custom logic

Example: log in the console and send email if there is an outage:

```js
//-------------------
// server.js
//-------------------

watchmen.on('service_error', function(service, state){

/*
//Do here any additional stuff when you get an error
*/
var info = service.url_info + ' down!. Error: ' + state.error + '. Retrying in ' +
(parseInt(state.next_attempt_secs, 10) / 60) + ' minute(s)..';

console.log (info);


if (state.prev_state.status === 'success' && config.notifications.enabled){
email_service.sendEmail(
service.alert_to,
service.url_info + ' is down!',
service.url_info + ' is down!. Reason: ' + error
);
}
});

```

## Run watchmen
Expand All @@ -143,7 +206,7 @@ or more probably you would want to use **forever** to run it in the background

$ forever start watchmen.js

### Run the web app to display status reports**
### Run the web app

$ forever start webserver/app.js 3000 #(where 3000 is the port you want to use).

Expand All @@ -158,16 +221,15 @@ Run the tests with mocha:

**1.0.alpha1 Major changes and improvements**

- Storages are now plugable. Redis storage is used by default but you can create your own : couchdb, mongodb, text file, etc (see lib/storage).
- Ping services are now plugable. For now we have http and smtp (smtp is just checking tcp connection right now). You can create your own or improve the existent ones easily.
- Watchmen daemon now inherits from events.EventEmitter, so you can instanciate it and subscribe to the events of your choice (service_error, service_back, etc) to implement your custom logic (see server.js).
- Knockout.js has been removed. It uses handlebars instead. Faster, simpler code, avoid some client side memory leacks.
- Client side is using moment.js for rendering dates.
- Express routes now are handled on /routes
- Mocha is used for unit testing. Mocked storages and ping services are used.
- More features, less code. :-)
- Configuration is now in separate files, under /config directory
- Better reporting UI. **Uptime statistics**. Outages count, warnings count.
- **Storages** are now pluggable. `redis` storage is used by default but you can create your own : `couchdb`, `mongodb`, text file, etc (see lib/storage).
- **Ping services** are also pluggable now. So far you can use `http` and `smtp` (`smtp` is just checking tcp connection right now). You can create your own or improve the existent ones easily.
- Watchmen daemon now inherits from `events.EventEmitter`, so you can instanciate it and subscribe to the events of your choice (service_error, service_back, etc) to implement your custom logic (see server.js).
- [Knockout.js](http://knockoutjs.com) has been removed. Watchmen uses handlebars now instead. Faster, simpler code, and avoids some client side memory leacks.
- Client side is using [moment.js](http://momentjs.com) for rendering dates.
- [Express.js](http://expressjs.com) routes now are handled on /routes
- [Mocha](visionmedia.github.com/mocha/ ) is used for unit testing. Mocked storages and ping services are used.
- Configuration is now spread in separate files, under the /config directory
- Better reporting web interface. **Uptime statistics**. Outages count, warnings count.

**0.9**

Expand Down Expand Up @@ -237,6 +299,7 @@ Run the tests with mocha:

## TODO

- Event pagination in service details
- Twitter integration (pipe events to a twitter account)
- Security (authentication for accesing the web UI and or editing stuff)
- Google charts
Expand Down

0 comments on commit c253d3c

Please sign in to comment.