linux jar运行监控 mo,Monitr: Monitr 是 Nodejs 进程监视工具,此模块目前只用于 Linux 上...

monitr

Nodejs process monitoring module

This package is tested only with Node.js LTS versions.

Note: This module currently works only on Linux operating systems.

External statistics reporting

This module starts a separate thread within the Nodejs runtime that

monitors and collects statistics about the running nodejs process.

These statistics are then sent as JSON messages via UDP datagrams over

a local domain socket.

Here is the list of data the module reports periodically:

{ status:

{ pid: ,

ts: ,

cluster: ,

reqstotal: ,

utcstart: ,

events: ,,

cpu: ,

mem: ,

cpuperreq: ,

oreqs: ,

sys_cpu: ,

oconns: ,

user_cpu: ,

rps: ,

kbs_out: ,

elapsed: ,

kb_trans: ,

jiffyperreq: ,

gc: {

scavenge: { count: , elapsed_ms: , max_ms: },

marksweep: { count: , elapsed_ms: , max_ms: }

}

}

}

GC introspection

It provides the running nodejs application with the ability to

introspect garbage collection activity by creating read-only

properties at process.monitor.gc that reports:

count: number of times GC stop-the-world events occurred

elapsed: cumulative time (in milliseconds) spent in GC

Installation

With npm do:

npm install monitr

Usage

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 datagram socket name to write the stats. Defaults to /tmp/nodejs.mon

Health Status

Monitr supports custom health functionality whereby the app can report its own health.

The following methods are added to process.monitor to set and get the health information.

setHealthStatus(isDown, statusCode)

isDown()

getStatusCode()

getStatusTimestamp() - Return seconds when setHealthStatus was last called

getStatusDate() - Return Date object

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

health_status_timestamp: ,

health_is_down: ,

health_status_code:

Handling HUP events

Monitr installs a custom SIGHUP handler which will optionally

print out a NodeJS stack backtrace of the Javascript currently being

executed. This can be useful for debugging where a NodeJS process may

be stuck.

Implementation

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.

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

It calls the process.monitor.* methods to report total requests since

monitoring started (reqstotal), current requests in flight

(oreqs), current open connections (oconns) and total data returned

since monitoring started (kb_trans). Note: oreqs may be greater

than oconns when keepalive is enabled.

It attaches to the v8 garbage collection hooks to instrument (for each

GC type) the following stats for each reporting interval.

count : number of times GC type invoked

elapsed_ms: total elapsed time nodejs thread is blocked

max_ms: maximum time spent blocked by any one GC event

Example

Please refer to examples/README.md for examples showing the use of these functions.

Build Status

c6a350cdd10c0959d26f3ad9b545ac0f.png

Node Badge

e08db57721aa12a30a75686bf598311f.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值