Research
Security News
Malicious PyPI Package ‘pycord-self’ Targets Discord Developers with Token Theft and Backdoor Exploit
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
@esmj/monitor
Advanced tools
Node.js performance measurement metrics (cpu, memory, event loop, gc)
The @esmj/monitor
is module for collecting node metrics from native node API.
npm install @esmj/monitor
It works for both Javascript modules (ESM and CJS).
// server.js
import { createMonitoring } from '@esmj/monitor';
const { monitor, metricsHistory } = new createMonitoring();
const { unsubscribe } = monitor.subscribe((metric) => {
console.log(metric);
// {
// cpuUsage: { user: 1692, system: 925, percent: 0.26 },
// eventLoopDelay: {
// min: 20.07,
// max: 21.15,
// mean: 20.78,
// stddev: 0.38,
// percentile80: 21.08
// },
// eventLoopUtilization: {
// idle: 992.72,
// active: 7.85,
// utilization: 0.01
// },
// loadAverage: {
// minute1: 3.38,
// minute5: 8.28,
// minute15: 9.15
// },
// memoryUsage: {
// percent: 5.23,
// rss: 54.2,
// heapTotal: 20.2,
// heapUsed: 17.74,
// external: 0.9,
// arrayBuffers: 0.07
// },
// gc: { entry: null },
// process: {
// pid: 53509,
// ppid: 53480,
// platform: 'darwin',
// uptime: 14.656514084,
// version: 'v18.12.1'
// }
// }
});
monitor.start();
setTimeout(() => {
console.log(metricsHistory.percentile('cpuUsage.percent', 80)); // 1
console.log(metricsHistory.percentile('memoryUsage.rss', 80)); // 61
console.log(metricsHistory.trend('memoryUsage.rss').predict()); // 65
}, 5000);
setTimeout(() => {
console.log(metricsHistory.size) // 15;
console.log(metricsHistory.current) // return last captured metric structure
unsubscribe();
monitor.stop();
console.log(metricsHistory.percentile('cpuUsage.percent', 80)); // undefined
console.log(metricsHistory.percentile('memoryUsage.rss', 80)); // undefined
}, 15000);
Create a new instance of Monitor.
Type: object
Configure options for the new instance of Monitor.
Type: integer
Default: 1000
Measure interval metric.
Monitoring start measure node metric.
Monitoring stop measure node metric.
Subscribe listener for metrics.
Returns a subscription object with unsubscribe method.
Remove subscription.
Monitoring add measure new metric.
Type: Metric
Add new metric to monitoring.
Remove defined metric from monitoring.
Create a new instance of Monitor.
Type: object
Configure options for the new instance of MetricsHistory.
Type: integer
Default: 60
FIFO size of array for calculating percentile and linear regressions.
Returns defined percentile for measured metric
Type: String
Path in measured metric structure.
Type: Number
Percentile number for FIFO array
Memoized version of percentile function. Cache is cleared after capture new metric.
Returns linear regression variables slope
, yIntercept
and predict
function for measured metric.
Type: String
Path in measured metric structure.
Type: Number
Defined how much records use for calculating linear regression. Default is use all records from FIFO array.
Memoized version of trend function. Cache is cleared after capture new metric.
FAQs
Node.js performance measurement metrics (cpu, memory, event loop, gc)
The npm package @esmj/monitor receives a total of 6 weekly downloads. As such, @esmj/monitor popularity was classified as not popular.
We found that @esmj/monitor 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.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.