Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@11ways/process-monitor
Advanced tools
Monitors the CPU and memory usage for a PID or collection of PIDs.
Monitors the CPU and memory usage for a PID or collection of PIDs asynchronously and emits an event with a stats object which includes information about the specified PID. Allows a user-specified format string for creating a friendly status message.
Install the module:
npm install @11ways/process-monitor
Use it in your script:
var procmon = require('@11ways/process-monitor');
Monitor a single PID or multiple PIDs:
// Single PID
var single = procmon.monitor({ pid: 1, interval: 5000 }).start();
// Multiple PIDs
var multi = procmon.monitor({ pid: [1, 2, 3] }).start();
Handle the stats
response - an event will be emitted for each of the specified PIDs and includes the PID:
single.on('stats', function(stats) {
console.dir(stats); // Outputs: { pid: 1, cpu: '0.0', mem: '2248', out: '' }
})
Note: if a PID is not found, the resulting cpu and mem properties will be 0.0 and 0 respectively.
Generated code documentation is available here and in the docs directory. This documentation is generated using
docco-husky
- to regenerate the documentation, run $ docco-husky lib/*
.
Currently the monitor
function accepts the following configuration options:
The pid
option may be a single process ID or an array from process IDs to monitor. The PID is also included in the stats
object on when the stats
event is emitted.
procmon.monitor({ pid: 1}).start();
procmon.monitor({ pid: [1, 2, 3] }).start();
The rate in milliseconds at which the processes are checked and the stats event is emitted. The rate defaults to 1000 miliseconds.
procmon.monitor({ pid: 1, interval: 5000 }).start();
Specify a format string that will be updated in the stats
object on update. Use {pid}
, {cpu}
, and {mem}
to output a friendly message on update.
procmon.monitor({
pid: [1, 2],
interval: 5000,
format: 'PID {pid} - {cpu}% CPU - {mem} memory'
}).start();
procmon.on('stats', function(stats) {
console.log(stats.out);
});
There are two supported techniques for reading process information.
procmon.monitor({
pid: 1,
interval: 5000,
technique: 'ps'
}).start();
ps
(default): Uses the ps
command to find CPU and memory usage. CPU value returned from the ps
command is a lifetime average and does not reflect the current usage.proc
: Uses information stored in the /proc files to calculate current CPU usage. Implementation comes from the node-usage module. Only supported on Linux.usage
with pidusage
, which doesn't require C-bindingsformat
to the configuration object which accepts a format for the output (the out
property of the stats
object). Uses stringformat which allows the use of {cpu}
, {mem}
, and {pid}
in the format string.Copyright (c) 2012 Modulus Licensed under the MIT license.
FAQs
Monitors the CPU and memory usage for a PID or collection of PIDs.
We found that @11ways/process-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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.