What is ps-list?
The ps-list npm package is a tool for listing running processes on the system. It provides a simple and cross-platform way to retrieve information about the processes running on a machine, including their PID (Process ID), name, and other details. This can be particularly useful for monitoring system health, debugging applications, or managing system resources programmatically.
What are ps-list's main functionalities?
Fetching a list of running processes
This feature allows you to fetch a list of all running processes on the system. The returned list includes details such as the process ID (pid), name, and other process-related information. This can be useful for monitoring which processes are currently active.
const psList = require('ps-list');
(async () => {
const processes = await psList();
console.log(processes);
})();
Fetching running processes with detailed information
By setting the 'all' option to true, you can fetch a more detailed list of running processes. This includes additional information such as the process's CPU and memory usage, which can be crucial for more in-depth system monitoring and analysis.
const psList = require('ps-list');
(async () => {
const processes = await psList({all: true});
console.log(processes);
})();
Other packages similar to ps-list
pidusage
The pidusage package provides statistics about running processes, such as CPU and memory usage, similar to what ps-list offers with its detailed information feature. However, pidusage focuses more on the resource usage aspect of processes rather than just listing them.
process-list
Similar to ps-list, process-list is designed to retrieve information about the system's running processes. It offers detailed insights, including memory and CPU usage, and has a slightly different API. The choice between process-list and ps-list might come down to specific API preferences or additional minor features one or the other might offer.
ps-list
Get running processes
Works on macOS, Linux, and Windows.
Install
npm install ps-list
Usage
import psList from 'ps-list';
console.log(await psList());
API
psList(options?)
Returns a Promise<object[]>
with the running processes.
On macOS and Linux, the name
property is truncated to 15 characters by the system. The cmd
property can be used to extract the full name.
The cmd
, cpu
, memory
, and uid
properties are not supported on Windows.
options
Type: object
all
Type: boolean
Default: true
Include other users' processes as well as your own.
On Windows this has no effect and will always be the users' own processes.
Related
- fastlist - The binary used in this module to list the running processes on Windows