Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

feedhenry-staff/rhmap-stats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published