abbshr / node_vm_stats

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node.js VM layer metric statistics utility

In Node.js 8.x.

Just a lite version newrelic-agent, because I just wanna to collection some vm metrics ;)

yeah, some code from newrelic-agent ;)

This module uses newrelic/native-metrics package inside, to collect underlying metrics, they are:

  • process cpu usage/utilization
  • memory usage
  • v8 heap space stats
  • gc duration and type
  • eventloop tick related
  • amount of backend threads
  • amount of opend fds

Install

npm i github:abbshr/node_vm_stats

API

class: VMStats

constructor

const stats = require("vm-stats")([configuration]);

start

stats.start

Usage

// in main module
const stats = require("vm-stats");
stats().start();

configuration

  • if no config object given, use $pwd/vm_stats.config.js
  • and if no $pwd/vm_stats.config.js found, use defauts config as below
  • if a config object pass to constructor, merge it with defaults config
FREQUENCY = 15 * 1000; // unit: millisecond, how often do you want to collect the metrics
{
  gc: true,
  memory: { frequency: FREQUENCY },
  eventLoop: { frequency: FREQUENCY },
  cpuTime: { frequency: FREQUENCY },
  thread: { frequency: FREQUENCY },
  fd: { frequency: FREQUENCY },
  frequency: FREQUENCY,

  // a callback to report metrics and theirs type
  report(type, pid, metrics) { console.log(type, pid, metrics); }
}

Metrics details & others

About


Languages

Language:JavaScript 100.0%