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
//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");
//as a middleware of a route
route.use(function(req,res,next){
session.count("my_endpoint");
next();
});
route.use(function(req,res,next){
session.count("user_login", 1,["user="+req.query.userName]);
next();
});
// monitor database response
var timer = session.time("list_user_collection");
userCollection.find({},function(err,userList){
session.timeEnd(timer);
});
// monitor database response
var timer = session.time("list_user_collection", ["user=test"]);
userCollection.find({},function(err,userList){
session.timeEnd(timer);
});
#License
MIT