Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@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.
The npm package @11ways/process-monitor receives a total of 0 weekly downloads. As such, @11ways/process-monitor popularity was classified as not popular.
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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.