
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
metrics-process
Advanced tools
Utility to get current process metrics.
$ npm install metrics-process
var getMetrics = require( 'metrics-process' );
Gets the current process metrics and invokes a provided callback. The callback should accept two arguments: error and metrics.
function onMetrics( error, metrics ) {
if ( error ) {
throw new Error( error );
}
console.log( JSON.stringify( metrics ) );
}
getMetrics( onMetrics );
If no error is encountered while getting process metrics, error is null. The metrics object is comprised as follows:
{
"pid": 14847,
"uptime": 0,
"mem": {
"rss": 10932.224,
"heapFree": 1934.048,
"heapTotal": 4083.456,
"heapUtilization": 0.5263698200739766,
"memUsed": 13017.088,
"utilization": 0.00151824951171875
},
"cpu": {
"utilization": 0
},
"lag": 0
}
The following metrics are reported...
The process id.
The number of milliseconds the process has been running.
The resident set size, which is the portion of memory held in RAM, as opposed to swap or disk. This metric is reported in kilobytes.
The amount of memory remaining from which newly created objects will originate. This metric is reported in kilobytes.
The total amount of memory from which newly created objects can originate. This metric is reported in kilobytes.
The decimal percentage of utilized heap space.
The amount of memory used by the process. This metric is reported in kilobytes.
Used memory as a fraction of total system memory.
A decimal percentage describing how much the process utilizes the CPU.
The average number of milliseconds a request has to wait in Node's event queue before being processed. An excess lag means that the process is overloaded. See node-toobusy for more information.
var getMetrics = require( 'metrics-process' );
for ( var i = 0; i < 10; i++ ) {
setTimeout( onTimeout, 1000*i );
}
function onTimeout() {
getMetrics( onMetrics );
}
function onMetrics( error, metrics ) {
if ( error ) {
throw new Error( error );
}
console.log( JSON.stringify( metrics ) );
}
To run an example from the top-level application directory,
$ node ./examples/index.js
Metrics names mirror the conventions set forth in doc-metrix.
Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage directory. To access an HTML version of the report,
$ make view-cov
Copyright © 2014-2015. Athan Reines.
FAQs
Utility to get current process metrics.
The npm package metrics-process receives a total of 6 weekly downloads. As such, metrics-process popularity was classified as not popular.
We found that metrics-process demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.