health
v0.3.0
Published
Resource status monitoring library.
Downloads
3,107,279
Readme
Health
Health is a resource status monitoring library.
This is handy when you want to monitor the status of multiple resources using a simple configuration file. For example, if your application requires a web service and a MongoDB database to be available, Health module can monitor those resources and return status ok/fail against each resource along with the response time.
It also supports result caching via ttl attribe of each resource, which is handy when you want to monitor multiple resources at a different interval or to reduce the load on certain resources.
Installation
npm install -g health
Usage
// use default formatter
var health = new (require('health'))(
setup: [ { name: 'google', uri: 'http://google.com' } ]
);
// use built-in formatter (html, text, or xml)
var health = new (require('health'))(
setup: [ { name: 'google', uri: 'http://google.com' } ],
formatter: 'html'
);
// use custom formatter function
var health = new (require('health'))(
setup: [ { name: 'google', uri: 'http://google.com' } ],
formatter: function (results) {
return results.join('|');
}
);
// check resources
health.check(function (err, result) {
});
From command-line:
health -f html -s health.json check
Configuration
Health setup is just a simple JSON:
[
{ "name": "Google", "uri", "http://google.com", "statusCodes": [ 200 ] },
{ "name": "GMail", "uri", "https://mail.google.com", "timeout": "1000" },
{ "name": "MongoDB", "uri": "mongodb://somehost:27017", "timeout": 200, "ttl": 30000 },
{ "name": "Temp", "uri": "file:///tmp", "mode": "777", "ttl": 360000 }
]
Colophon
Build reports: