README
Pingup
Usage
var pingup = require('pingup');
app.get('/monitoring', pingup.status(options));
Options
Add monitoring for your Redis or MongoDB servers.
Redis
Pass a redis
client to pingup.status()
var redis = require('redis');
var redisClient = redis.createClient(REDIS_URL);
app.get('/monitoring', pingup.status({redis: redisClient}));
MongoDB
Pass a mongo
client to pingup.status()
var mongodb = require('mongodb');
mongodb.MongoClient.connect(MONGO_URL, function(err, mongoClient) {
if (err) {
return; // Do something with err
}
app.get('/monitoring', pingup.status({mongo: mongoClient}));
});
Multi-monitoring
You can also pass many clients of the same type, by passing an array instead of a single client.
var redis = require('redis');
var redisClient1 = redis.createClient(REDIS_URL_1);
var redisClient2 = redis.createClient(REDIS_URL_2);
app.get('/monitoring', pingup.status({
redis: [
redisClient1,
redisClient2
]
}));
You can pass both redis
and mongo
to pingup.status()
, of course.
var redis = require('redis');
var redisClient1 = redis.createClient(REDIS_URL_1);
var redisClient2 = redis.createClient(REDIS_URL_2);
var mongodb = require('mongodb');
mongodb.MongoClient.connect(MONGO_URL, function(err, mongoClient) {
if (err) {
return; // Do something with err
}
app.get('/monitoring', pingup.status({
redis: [
redisClient1,
redisClient2
],
mongo: mongoClient
}));
});
Timeout
Pass timeout: seconds
to pingup.status()
. Default is 30 seconds.
pingup.status({timeout: 5}); // set a 5 seconds timeout for each service
Try it
$ curl http://localhost:3000/pingup
{
"web": {
"up": true
},
"redis.0": {
"up": true
},
"redis.1": {
"up": true
},
"mongo": {
"up": true
}
}
Tests
To run the test suite first invoke the following command within the repo, installing the development dependencies:
$ npm install
then run the tests:
$ npm test