https://github.com/ibrahimgunduz34/process-list
A simple library to retrieve the running process list for Node.js
https://github.com/ibrahimgunduz34/process-list
backend freebsd linux monitoring nodejs os osx system-information windows
Last synced: 3 months ago
JSON representation
A simple library to retrieve the running process list for Node.js
- Host: GitHub
- URL: https://github.com/ibrahimgunduz34/process-list
- Owner: ibrahimgunduz34
- Created: 2022-04-22T20:36:18.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-25T13:01:19.000Z (about 4 years ago)
- Last Synced: 2024-04-29T20:22:34.925Z (about 2 years ago)
- Topics: backend, freebsd, linux, monitoring, nodejs, os, osx, system-information, windows
- Language: JavaScript
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://github.com/ibrahimgunduz34/process-list/actions/workflows/npm-publish.yml)
# ProcessList
It's a library that simply wrap the `ps` command in order to access the active process list from your application.
## Installation:
```bash
$ npm install @ibrahimgunduz34/process-list
```
## Reference:
| Method | Description |
|----------------------------------------|-----------------------------------|
| getList(asArray, options): Promise<[]> | Returns list of running processes |
### getList(asArray, options): Promise<[]>:
#### Parameters:
| Parameter | Type | Required | Default | Description |
|------------|----------|----------|---------------|-----------------------------------|
| asArray | boolean | No | false | It allows the method to return the running processes as an array. The first item of the array would be the column list. By default, it takes false value and the method would returns the running processes as a list of objects that contains the process details with their column names. |
| options | array | No | ['a','u','x'] | It allows passing extra arguments to the ps command. |
#### Return:
It returns a Promise with the list of running processes as objects or arrays.
## Usage:
```javascript
const ProcessList = require('process-list');
// ...
const processes = await ProcessList.getList();
/**
[
{
USER: 'root',
PID: '6029',
'%CPU': '0.0',
'%MEM': '0.0',
VSZ: '0',
RSS: '0',
TTY: '?',
STAT: 'I',
START: '09:56',
TIME: '0:00',
COMMAND: '[kworker/u4:2-events_unbound]'
},
{
USER: 'root',
PID: '6036',
'%CPU': '0.0',
'%MEM': '0.0',
VSZ: '0',
RSS: '0',
TTY: '?',
STAT: 'I',
START: '09:56',
TIME: '0:00',
COMMAND: '[kworker/0:2-events]'
},
{
USER: 'vagrant',
PID: '6385',
'%CPU': '0.0',
'%MEM': '3.2',
VSZ: '512544',
RSS: '32736',
TTY: 'pts/0',
STAT: 'Rl+',
START: '10:03',
TIME: '0:00',
COMMAND: 'node src/ntop.js'
}
]
*/
//...
const processes = await ProcessList.getList({asArray: true});
/**
[
[
'USER',
'PID',
'%CPU',
'%MEM',
'VSZ',
'RSS',
'TTY',
'STAT',
'START',
'TIME',
'COMMAND'
],
[
'root',
'6029',
'0.0',
'0.0',
'0',
'0',
'?',
'I',
'09:56',
'0:00',
'[kworker/u4:2-events_unbound]'
],
[
'root',
'6036',
'0.0',
'0.0',
'0',
'0',
'?',
'I',
'09:56',
'0:00',
'[kworker/0:2-events]'
],
[
'vagrant',
'6385',
'0.0',
'3.2',
'512544',
'32736',
'pts/0',
'Rl+',
'10:03',
'0:00',
'node src/ntop.js'
]
]
*/
```