napm-agentx

0.0.2 • Public • Published

napm-agentx

napm-agentx是Node监控系统的agent命令程序,用于协助Node性能数据上报和问题诊断。

安装

$ npm install napm-agentx -g

以上命令会将napm-agentx安装为一个全局的命令行工具。

命令行用法

napm-agentx需要一个配置文件来进行使用,napm-agentx仅会在配置指定下的目录执行命令或读取日志。

该配置格式如下:

{
  "server": "<SERVER IP>:8080",
  "appid": "<YOUR APPID>",
  "secret": "<YOUR SECRET>",
  "logdir": "</path/to/your/log/dir>",
  "reconnectDelay": 10,
  "heartbeatInterval": 60,
  "reportInterval": 60,
  "error_log": [
    "</path/to/your/error.log>",
    "您的应用在业务层面产生的异常日志的路径",
    "例如:/root/.logs/error.#YYYY#-#MM#-#DD#-#HH#.log",
    "可选"
  ]
}

配置中的#YYYY#、#MM#、#DD#、#HH#是通配符,如果您的异常日志是按时间生成的,请使用它。

以上有什么不懂可咨询:hzkangdongyang@corp.netease.com

保存为config.json

完成配置后,请使用以下命令进行执行:

$ nohup napm-agentx config.json &

napm-agentx将以常驻进程的方式执行。

PM2用法

npm install napm-agentx --save

启动脚本:

const pm2 = require('pm2');

pm2.connect((err) => {
    pm2.start({
        script: 'node_modules/napm-agentx/index.js',
        name: '<app_name>',
        env: {
            APPID: "<YOUR APPID>",
            SECRET: "<YOUR SECRET>",
            // string or array
            ERROR_LOG: "</path/to/your/error.log>",
            LOG_DIR: "</path/to/your/log/dir>",
            SERVER: "<SERVER>"
        }
    }, (err, apps) => {
        pm2.disconnect();
        if (err) {
            throw err;
        }
    });
  })

使用Node标准化启动容器

ndp、overmind中选择启动容器作为启动模版,只需要需要提供appid和secret即可,启动app的时候自动自动

License

The napm-agentx is released under the MIT license.

napm-agentx第一版非自己开发,只是整合了aliyun-node的commands和agentx,结合业务对代码做一些小改动,所有版权归aliyun-node所有。

Readme

Keywords

none

Package Sidebar

Install

npm i napm-agentx

Weekly Downloads

3

Version

0.0.2

License

MIT

Unpacked Size

67.6 kB

Total Files

40

Last publish

Collaborators

  • frontdog