1.0.1 • Published 11 years ago

ravenwall v1.0.1

Weekly downloads
26
License
-
Repository
-
Last release
11 years ago

Ravenwall

Monitor the the health and various custom variables for your node.js processes and let Ravenwall check and store the data. Use Ravenwall.com to view your node.js processes' data in a dashboard, or send email/sms/phone alerts based on the captured data.

Ravenwall is a Monitoring-as-a-Service company that has various levels of service, starting at free.

Creates a http status server on a specified port that will emit either human or json stats related to the running process. It always emits a base set of values, values you specify, or it can be configured with Synch or Asynch helpers to add your own values in.

NOTE: You will have to have your port open to Ravenwall's workers for them to be able to check this port's status. See (the node list)https://api.ravenwall.com/nodes for the live list of Ravenwall worker IP addresses.

var mystatus = require("ravenwall").createStatusListener().listen(8989);

This should then create a server running at port 8989 that you can connect to see your health stats.

E.g. on localhost http://localhost:8989/status.txt http://localhost:8989/status.json

install

with npm, do:

npm install ravenwall

Using your own http server

Instead of using the bundled http server, you can attach the status object to your own Express, Restify, or other http server already in your system. Here is an example using Express.js:

var express = require('express');
var app = express();

// Set up ravenwall & the process status object
var ravenwall = require("ravenwall");
var status = ravenwall.createStatusObject({});
// Use the provided async helpers
status.registerAsyncHelper(ravenwall.procstats);
status.registerAsyncHelper(ravenwall.sysstats);
status.registerAsyncHelper(ravenwall.memstats);

// Set up a json health page to show your stats
app.get("/status.json", function (req, res) {
  status.getStatus(function (stats) {
    return res.json(stats);
  });
});

// your routes ...

See a more fleshed out example using express.js in the examples folder.

methods

createStatusListener([initial, ravenwall_config])

Create a new status listener object, optionally with some initial values. Optionally send some ravenwall_config to register this process to be checked by Ravenwall's monitoring services.

ravenwall_config is an object with the following settings/options:

var ravenwall_config = {
  api_token: "A2Zfz...", // [REQUIRED] Your account's API token. Visit [Ravenwall](https://ravenwall.com) to sign up or retreive your API key.
  name: "Some Name", // [REQUIRED} A name for what you're monitoring, e.g. "Express Server #3"
  host: "...", // [REQUIRED] Your hostname or external ip address that the Ravenwall monitoring nodes can reach this via.
  scheme: "http", // or https -- Default: "http"
  repeat_millis: 60000, // Default 60000 
  locations: "US_OR,US_VA" // see Ravenwall section above about choosing locations Default: "US_OR,US_VA"
};

StatusListener.listen(...)

Start the status listener's http server. Conforms to Node.js http server's .listen().

Returns the underlaying StatusObject that will be reported on.

StatusObject

The internal status object storing and fetching the values to display.

createStatusObject(initial)

Create a status object, useful for feeding into createStatusListener as initial values.

StatusObject.getStatus(callback)

Execute callback(status) after processing any registered helpers.

StatusObject.set(key, value)

Safely set a status value. Will initialize the key if not yet present.

StatusObject.increment(key)

Safely increment the value stored at a key, initializing the key if not yet present.

var capped = StatusObject.cappedHistory(key, max_entries)

Create a fixed-array of max_entries max size. Add entries with capped.push(...). This will create an internal helper that will emit the min/max/mean for this key on each getStatus call.

StatusObject.incrementHash(key, member)

Increment key/member value stored as a hash, useful for creating related buckets of counters.

E.g.

method: {
  GET: 201,
  POST: 19,
  PUT: 10
}

StatusObject.registerHelper(key, helper)

Create a synchronous helper to populate "key".

E.g.

mystatus.registerHelper("active_connections", function () {
  return io.sockets.clients().length;
});

StatusObject.registerAsyncHelper(helper)

Create an asynchronous helper to set status values.

E.g.

mystatus.registerAsyncHelper(function (status, next) {
  redis_client.multi()
   .scard("accounts")
   .scard("users")
   .get("burger_count")
   .get("foo")
   .exec(function (e, replies) {
      status.num_accounts = replies.shift();
      status.num_users = replies.shift();
      status.burger_count = replies.shift();
      status.num_foos = replies.shift(); 
      next();
    });
}); 
1.0.1

11 years ago

1.0.0

11 years ago

0.1.7

11 years ago

0.1.6

11 years ago

0.1.5

11 years ago

0.1.4

11 years ago