0.1.2 • Published 11 years ago

vitals v0.1.2

Weekly downloads
3
License
-
Repository
-
Last release
11 years ago

Vitals

Vitals is a module that will collect health statistics for process ids past to it, currently collections cpu time, memory usage and uptime.

Installation

$ npm install vitals

Features

  • Windows & Unix support
  • Meta data support

Options

  • interval the interval in which to poll the processes (Default 3000ms)

Events

  • started when the monitor is activated
  • stopped when the monitor has stopped monitoring the processes
  • added when a process has been added to the monitor
  • removed when a process has been removed from the monitor, died will be in the meta data if removed due to process stopping
  • data the processes health data

Usage

Initiate vitals and add processes

var vitals = require('vitals');

Adding processes to vitals

vitals.add(pid, [meta]);

vitals.add([
    {pid: pid, meta: meta}
])

Getting monitored processes

var proc = vitals.get(pid);
var procs = vitals.get([pid,pid]);
var procs = vitals.get(function(proc) {
                    return proc.meta.key == 'value';
                });

Removing processes to vitals

vitals.remove(pid);

vitals.remove([pid, pid, pid]);

vitals.remove(function(proc) {
    return proc.meta.key = 'value';
})

vitals.remove(); //removes all

Starting / Stopping

vitals.start();

vitals.stop();

Count number of processes being monitored

vitals.length

Events

vitals.on('started', function() {
    
});

vitals.on('added', function(proc) {
    //proc.pid && proc.meta
});

vitals.on('removed', function(proc) {
    //proc.pid && proc.meta && proc.meta.died if process exited
})

vitals.on('data', function(proc, data) {
    //proc.pid && proc.meta
    //data.cputime data.memoryUsage data.uptime
});

vitals.on('stopped', function() {
    
});

Running tests

$ npm install
$ npm test

License

(The MIT License)

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

12 years ago