rhmap-stats
v1.0.5-alpha
Published
RedHat Mobile Application wrapper for stats-influxdb
Downloads
78
Readme
RedHat Mobile Application system monitoring and stats lib
This lib is tightly related to RHMAP and can only work with RHMAP.
It is based on stats-influxdb
lib
#Install
npm install --save rhmap-stats
#Usage Examples
Monitor system stats
//in RHMAP node.js app:
var stat=require("rhmap-stats");
var session=stat.init({
host: "myInfluxDb", //influxdb hostname or ip address ,
port: 4444 //influxdb udp port
});
stat.monit.start(session,"cpu",1000); //monitor vm cpu usage every 1000 ms
stat.monit.start(session,"mem",1000); //monitor vm mem usage every 1000 ms
stat.monit.start(session,"pidusage",1000); //monitor this process mem and cpu usage every 1000 ms
stat.monit.start(session,"disk",3600*1000); //monitor vm disk usage (/) every hour
To stop the monitoring
stat.monit.stop(session,"cpu");
stat.monit.stop(session,"mem");
Simple Endpoint counter
//as a middleware of a route
route.use(function(req,res,next){
session.count("my_endpoint");
next();
});
Endpoint counter with parameters
route.use(function(req,res,next){
session.count("user_login", 1,["user="+req.query.userName]);
next();
});
Time elapse statistics
// monitor database response
var timer = session.time("list_user_collection");
userCollection.find({},function(err,userList){
session.timeEnd(timer);
});
Time elapse statistics with parameters
// monitor database response
var timer = session.time("list_user_collection", ["user=test"]);
userCollection.find({},function(err,userList){
session.timeEnd(timer);
});
#License
MIT