Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thlorenz/ps-aux
Supplies process information via the ps aux command.
https://github.com/thlorenz/ps-aux
Last synced: 24 days ago
JSON representation
Supplies process information via the ps aux command.
- Host: GitHub
- URL: https://github.com/thlorenz/ps-aux
- Owner: thlorenz
- License: mit
- Created: 2014-08-28T00:02:06.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-05T20:50:34.000Z (over 10 years ago)
- Last Synced: 2024-11-23T01:15:55.855Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 223 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ps-aux [![build status](https://secure.travis-ci.org/thlorenz/ps-aux.png)](http://travis-ci.org/thlorenz/ps-aux)
Supplies process information via the `ps aux` command.
Tested on Linux and OSX.
```js
var Psaux = require('psaux')
, psaux = Psaux();psaux.parsed(function (err, res) {
if (err) return console.error(err);
console.log(res);
})
``````js
[
{ 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](http://doctoc.herokuapp.com/)*
- [Installation](#installation)
- [API](#api)
- [Psaux](#psaux)
- [psaux::clearInterval()](#psauxclearinterval)
- [psaux::obtain(cb)](#psauxobtaincb)
- [psaux::parsed(cb)](#psauxparsedcb)
- [psaux::setInterval(opts)](#psauxsetintervalopts)
- [psaux::singleton() → {object}](#psauxsingleton-→-object)
- [Example](#example)
- [License](#license)## Installation
npm install ps-aux
## API
psaux::clearInterval()Clears any previously registered interval at which process information was obtained
and emitted.
- Source:
- See:
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:
user : id of the user that owns the process
pid : process id
%cpu : percent of the CPU usage
%mem : percent memory usage
vsz : virtual memory size
rss : resident set size
tty : controlling terminal
state : current state of the process (i.e. sleeping)
started : start time of process
time : how long the process is running
command : command line used to start the process (including args)
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
Name
Type
Description
parsed
boolean
if true, the process information is parsed before it is emitted (default:
true
)
interval
number
interval in milliseconds at which to emit process information (default:
20,000
)
- Source:
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);
- Source:
Returns:
a constructed
psaux
object
Type
object*generated with [docme](https://github.com/thlorenz/docme)*
## License
MIT