ps-aux 
Supplies process information via the ps aux command.
Tested on Linux and OSX.
var Psaux = require('psaux')
, psaux = Psaux();
psaux.parsed(function (err, res) {
if (err) return console.error(err);
console.log(res);
})
[
{ user: 'thlorenz',
pid: 1050,
'%cpu': 2.6,
'%mem': 1.3,
vsz: 4490356,
rss: 217636,
tty: '??',
state: 'S',
started: '5Aug14',
time: '123:03.05',
command: '/Applications/iTerm.app/Contents/MacOS/iTerm' },
{ user: '_coreaudiod',
pid: 257,
'%cpu': 0.6,
'%mem': 0.2,
vsz: 2553344,
rss: 38572,
tty: '??',
state: 'Ss',
started: '5Aug14',
time: '32:23.58',
command: '/usr/sbin/coreaudiod' },
[...]
]
Table of Contents generated with DocToc
Installation
npm install ps-aux
API
Psaux
Creates a psaux object.
psaux::clearInterval()
Clears any previously registered interval at which process information was obtained and emitted.
psaux::obtain(cb)
Obtains raw process information
Parameters:
| Name | Type | Description |
|---|---|---|
cb |
function | called back with an array of strings each containing information of a running process |
psaux::parsed(cb)
Obtains process information and parses it.
VSZ is the Virtual Memory Size. It includes all memory that the process can access, including memory that is swapped out and memory that is from shared libraries.
RSS is the Resident Set Size and is used to show how much memory is allocated to that process and is in RAM. It does not include memory that is swapped out. It does include memory from shared libraries as long as the pages from those libraries are actually in memory. It does include all stack and heap memory.
Parameters:
| Name | Type | Description |
|---|---|---|
cb |
function | called back with an array containing running process information process info:
|
psaux::setInterval(opts)
Causes the psaux object to obtain process information at the given interval and emit an event for each. When invoked, previously set intervals are cancelled.
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
Object | options Properties
|
psaux::singleton() → {object}
A singleton psaux instance. Use it in order to ensure that you only use one instance throughout your app.
Example
// foo.js
var psaux = require('ps-aux').singleton
psaux.setInterval({ parsed: true, interval: 5000 });
// bar.js
var psaux = require('ps-aux').singleton
psaux.on('info', console.log);
Returns:
a constructed psaux object
generated with docme
License
MIT