Vitals is a module that will collect health statistics for process ids past to it, currently collections cpu time, memory usage and uptime.
$ npm install vitals
- Windows & Unix support
- Meta data support
- Data sampling
intervalthe interval in which to poll the processes (Default 3000ms)maxSamplesthe maximum number of samples to retainsampleRatethe rate at which to sample data between 0 (disabled) and 1 for 100%, ie: 0.15 for 15% of the time
startedwhen the monitor is activatedstoppedwhen the monitor has stopped monitoring the processesaddedwhen a process has been added to the monitorremovedwhen a process has been removed from the monitor, died will be in the meta data if removed due to process stoppingdatathe processes health data
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 allStarting / Stopping
vitals.start();
vitals.stop();Count number of processes being monitored
vitals.lengthSampling Data
vitals.on('data', function(proc, data) {
//proc.meta._samples == Array[data, data, data]
//data.collected is the time the sample was collected
});
var proc = vitals.get(pid);
proc.meta._samplesEvents
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() {
});$ npm install
$ npm test
(The MIT License)