Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Latest commit

 

History

History
executable file
·
49 lines (43 loc) · 1.44 KB

README.md

File metadata and controls

executable file
·
49 lines (43 loc) · 1.44 KB

PSLook Build Status

Pslook is a NodeJS module retrieving processes informations on GNULinux systems without spawning a new process and in a full non-blocking way using the fs module and the proc filesystem only.

Usage

// List all processes
var ps=require('pslook');
ps.list(function(err, processes) {
	if(err) throw err;
	console.log(processes.length, processes[0].pid);
});

// List all node processes
var ps=require('pslook');
ps.list(function(err, process) {
	if(err) throw err;
	console.log(processes.length);
},{'search':/^node .*$/});

// List all processes and get their working dir + memory usage
var ps=require('pslook');
ps.list(function(err, process) {
	if(err) throw err;
	console.log(process.cwd);
	console.log(process.statm.size);
},{fields:ps.CWD|ps.STATM});

// Read every available informations for a process by its PID
var ps=require('pslook');
ps.read(aValidPID, function(err, process) {
	if(err) throw err;
	console.log(process.cwd);
	console.log(process.statm.size);
},{fields:ps.ALL});

Contributing

Feel free to pull your code if this codebase license is ok for you.

More OS Support

This library is only intended to run with Unix (particularly Linux) systems. If you wish to have MacOS/Windows support, write your own and mimic the API. I'll be glad to claim its existence there.