Naturally Pacifist Marsupials

    ps-aux

    0.2.1 • Public • Published

    ps-aux build status

    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.

    Source:

    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

    Source:

    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)
    Source:

    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

    License

    MIT

    Keywords

    Install

    npm i ps-aux

    DownloadsWeekly Downloads

    2

    Version

    0.2.1

    License

    MIT

    Last publish

    Collaborators

    • thlorenz