Class: Raindrops::Watcher

### Home Classes Methods

### In Files

- lib/raindrops/watcher.rb

### Parent

Object

### Namespace

- CLASS Raindrops::Watcher::Tailer

### Files

- LICENSE
- NEWS
- README

### Class/Module Index

Quicksearch

- Raindrops
- Raindrops::Aggregate
- Raindrops::Aggregate::LastDataRecv
- Raindrops::Aggregate::PMQ
- Raindrops::InetDiagSocket
- Raindrops::LastDataRecv
- Raindrops::Linux
- Raindrops::ListenStats
- Raindrops::Middleware
- Raindrops::Middleware::Proxy
- Raindrops::Middleware::Stats
- Raindrops::Struct
- Raindrops::TCP_Info
- Raindrops::Watcher

No matching classes.

# Raindrops::Watcher

Raindrops::Watcher is a stand-alone Rack application for watching any number of TCP and UNIX listeners (all of them by default).

It depends on the Aggregate RubyGem

In your Rack config.ru:

    run Raindrops::Watcher(options = {})

It takes the following options hash:

- :listeners - an array of listener names, (e.g. %w(0.0.0.0:80 /tmp/sock))

- :delay - interval between stats updates in seconds (default: 1)

Raindrops::Watcher is compatible any thread-safe/thread-aware Rack middleware. It does not work well with multi-process web servers but can be used to monitor them. It consumes minimal resources with the default :delay.

## HTTP endpoints

### GET /

Returns an HTML summary listing of all listen interfaces watched on

### GET /active/$LISTENER.txt

Returns a plain text summary + histogram with X-* HTTP headers for active connections.

e.g.: curl raindrops-demo.bogomips.org/active/0.0.0.0%3A80.txt

### GET /active/$LISTENER.html

Returns an HTML summary + histogram with X-* HTTP headers for active connections.

e.g.: curl raindrops-demo.bogomips.org/active/0.0.0.0%3A80.html

### GET /queued/$LISTENER.txt

Returns a plain text summary + histogram with X-* HTTP headers for queued connections.

e.g.: curl raindrops-demo.bogomips.org/queued/0.0.0.0%3A80.txt

### GET /queued/$LISTENER.html

Returns an HTML summary + histogram with X-* HTTP headers for queued connections.

e.g.: curl raindrops-demo.bogomips.org/queued/0.0.0.0%3A80.html

### POST /reset/$LISTENER

Resets the active and queued statistics for the given listener.

### GET /tail/$LISTENER.txt?active_min=1&queued_min=1

Streams chunked a response to the client. Interval is the preconfigured `:delay` of the application (default 1 second)

The response is plain text in the following format:

    ISO8601_TIMESTAMP LISTENER_NAME ACTIVE_COUNT QUEUED_COUNT LINEFEED

Query parameters:

- active_min - do not stream a line until this active count is reached

- queued_min - do not stream a line until this queued count is reached

## Response headers (mostly the same names as Raindrops::LastDataRecv)

- X-Count - number of samples polled

- X-Last-Reset - date since the last reset

The following headers are only present if X-Count is greater than one.

- X-Min - lowest number of connections recorded

- X-Max - highest number of connections recorded

- X-Mean - mean number of connections recorded

- X-Std-Dev - standard deviation of connection count

- X-Outliers-Low - number of low outliers (hopefully many for queued)

- X-Outliers-High - number of high outliers (hopefully zero for queued)

- X-Current - current number of connections

- X-First-Peak-At - date of when X-Max was first reached

- X-Last-Peak-At - date of when X-Max was last reached

# Demo Server

There is a server running this app at raindrops-demo.bogomips.org/ The Raindrops::Middleware demo is also accessible at raindrops-demo.bogomips.org/_raindrops

The demo server is only limited to 30 users, so be sure not to abuse it by using the /tail/ endpoint too much.

[Validate]

Generated with the Darkfish Rdoc Generator 2.