Giter Site home page Giter Site logo

saurabhmishra / monitr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yahoo/monitr

0.0 2.0 0.0 104 KB

Nodejs process monitoring tool. This module currently works only on LINUX. This module spawns a thread and begins monitoring the process.

License: BSD 3-Clause "New" or "Revised" License

monitr's Introduction

monitr

Nodejs process monitoring tool. This module currently works only on LINUX. This module spawns a thread and begins monitoring the process.

It looks up /proc/* files on the system to report CPU Usage. It looks up /proc/pid/* files on the system to report its own stats. It calls the process.monitor.* methods to report total requests, open connections and total data transferred.

process.monitor.* methods are set by lib/monitor.js.

Here is the list of data the module reports periodically:

 { status: 
     { pid: <pid of the node process>,
       ts: <current time stamp>,
       cluster: <process group id>,
       reqstotal: <total requests processed by this node process server>,
       utcstart: <when the process was started>,
       events: <number of new reports being processed since last stats reporting>,,
       cpu: <cpu usage>,
       mem: <memory usage>,
       cpuperreq: <cpu usage per request>,
       oreqs: <current open requests count>,
       sys_cpu: <system cpu load>,
       oconns: <current open connections count>,
       user_cpu: <user cpu load>,
       rps: <requests per second>,
       kbs_out: <kbs of data transferred since last stats reporting>,
       elapsed: <time elapsed since last event>,
       kb_trans: <total kbs of data transferred>,
       jiffyperreq: <cpu usage in terms of ticks per request> 
    }
 }

This package is tested only with Node versions 8 and 10.

install

With npm do:

npm install monitr

methods

var monitor = require('monitr');

start()

monitor.start();

Spawns a thread and monitors the process. Writes process stats every second to the socket path.

stop()

monitor.stop();

Terminates the thread and closes the socket.

setIpcMonitorPath(socketPath)

monitor.setIpcMonitorPath('/tmp/my-process-stats.mon');

Sets the handle to write the stats to. If not specified, defaults to /tmp/nodejs.mon

Health Status

Monitr is now enhanced with custom health functionality wherein the app can report its own health. Following methods are added to process.monitor to set and get the health information.

setHealthStatus(isDown, statusCode)
isDown()
getStatusCode()
getStatusTimestamp() - Return in seconds
getStatusDate() - Return Date object

Once setHealthStatus is invoked, the status json, described above, will have following additional fields.

health_status_timestamp: <timestamp when the setHealthStatus was invoked, in sec>,
health_is_down: <app is down or up, boolean>,
health_status_code: <health status code>

example

Please refer to the examples/README.md for details

Build Status

Build Status

Node Badge

NPM

monitr's People

Contributors

rohiniwork avatar vsacheti avatar sylvio avatar

Watchers

James Cloos avatar Saurabh Mishra avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.