procps 
Node.js bindings for procps, a library that provides information about processes using
the /proc filesystem, using the better maintained fork.
Supported Platforms
Unixes with a /proc directory only. Tested on arch linux and ubuntu.
Installation
npm install procps
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
Table of Contents generated with DocToc
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
Example
var procps = require('procps');
var proctab = procps.readproctab();
var bycommand = proctab.reduce(function (acc, p) {
acc[p.cmd] = p;
return acc;
}, {});
console.log(bycommand.node)
{ cutime: 0,
majFlt: 0,
vmSize: 661152,
resident: 0,
startCode: 4194304,
rgroup: 'kermit',
egid: 1000,
pgrp: 13690,
minFlt: 3199,
startTime: 3344937,
suser: 'kermit',
fgid: 1000,
processor: 0,
startStack: 76310960,
sgroup: 'kermit',
cmajFlt: 0,
flags: 4202496,
rss: 2431,
tid: 13834,
...
environ:
[ 'LC_PAPER=en_US.UTF-8',
...
'npm_node_execpath=/usr/bin/node' ],
nlwp: 2,
kstkEsp: 76309144,
fuser: 'kermit',
cmdline: [ 'node', 'example/readproctab.js' ],
sigcatch: '0000000180014202',
utime: 2,
vmRss: 9724,
wchan: 4294967295,
euid: 1000,
sigignore: '0000000000001000',
share: 0 }
API
Unofficial procps documentation.
So far readproctab has been implemented, but lots more to come, i.e. meminfo.
<!-- START docme generated API please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN docme TO UPDATE -->
<div>
<div class="jsdoc-githubify">
<section>
<article>
<div class="container-overview">
<dl class="details">
</dl>
</div>
<dl>
<dt>
<h4 class="name" id="readproctab::flags"><span class="type-signature"></span>readproctab::flags<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>A hashtable of all readproc flags.
Use these in order to fill/loose specific process properties.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy">
<li>
<a href="https://github.com/thlorenz/procps/blob/master/index.js">index.js</a>
<span>, </span>
<a href="https://github.com/thlorenz/procps/blob/master/index.js#L56">lineno 56</a>
</li>
</ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="readproctab::flagsFillAll"><span class="type-signature"></span>readproctab::flagsFillAll<span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>The flags used by default which cause readproc to fill all properties of each process.
Use them as a starting point to turn properties off selectively, i.e.:</p>
<pre><code class="lang-js">var flags = readproctab.flagsFillAll ^ readproctab.flags.PROC_FILLENV ^ readproctab.flags.PROC_FILLUSR;</code></pre>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy">
<li>
<a href="https://github.com/thlorenz/procps/blob/master/index.js">index.js</a>
<span>, </span>
<a href="https://github.com/thlorenz/procps/blob/master/index.js#L64">lineno 64</a>
</li>
</ul></dd>
</dl>
</dd>
</dl>
<dl>
<dt>
<h4 class="name" id="readproctab"><span class="type-signature"></span>readproctab<span class="signature">(<span class="optional">flags_</span>)</span><span class="type-signature"> → {Array.<Object>}</span></h4>
</dt>
<dd>
<div class="description">
<p>Calls underlying readproctab and returns results with the following ajustments:</p>
<ul>
<li>underscore_names are camel cased</li>
<li>Int64 values are converted to Int32 values</li>
</ul>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>flags_</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>flags passed to readproc, allow filling specific process properties only instead of all of them which is the default</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy">
<li>
<a href="https://github.com/thlorenz/procps/blob/master/index.js">index.js</a>
<span>, </span>
<a href="https://github.com/thlorenz/procps/blob/master/index.js#L35">lineno 35</a>
</li>
</ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>information about all processes running on the system</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.<Object></span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="sysinfo::getdiskstat"><span class="type-signature"></span>sysinfo::getdiskstat<span class="signature">()</span><span class="type-signature"> → {Object}</span></h4>
</dt>
<dd>
<div class="description">
<p>Gets statistics about disks/devices and partitions on the machine.</p>
<h5>Example DiskStats</h5>
<pre><code class="lang-js">{ disks:
[ { diskName: 'sda',
writes: 51770,
weightedMilliSpentIO: 121633,
reads: 14706,
partitions: 2,
milliWriting: 102280,
milliSpentIO: 24633,
milliReading: 19366,
mergedWrites: 131130,
mergedReads: 3164,
inprogressIO: 0,
writtenSectors: 1554100,
readsSectors: 486100 },
{ diskName: 'loop0',
...
partitions:
[ { partitionName: 'sda1',
requestedWrites: 1554100,
writes: 51693,
reads: 14553,
parentDisk: 0,
readsSectors: 483762 },
{ partitionName: 'sda2',
...
]}</code></pre>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy">
<li>
<a href="https://github.com/thlorenz/procps/blob/master/index.js">index.js</a>
<span>, </span>
<a href="https://github.com/thlorenz/procps/blob/master/index.js#L269">lineno 269</a>
</li>
</ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>with <code>disks</code> array and <code>partitions</code> array</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="sysinfo::getPidDigits"><span class="type-signature"></span>sysinfo::getPidDigits<span class="signature">()</span><span class="type-signature"> → {number}</span></h4>
</dt>
<dd>
<div class="description">
<p>Returns the number of digits in <code>PID_MAX</code>.</p>
<p><code>PID_MAX</code> specifies the value at which PIDs wrap around (i.e., the value in this file is one greater than the maximum PID).
The default value for this file, 32768, results in the same range of PIDs as on earlier kernels.</p>
<p>On <strong>32-bit platforms</strong>, <code>32768</code> is the maximum value for pid_max.
On <strong>64-bit systems</strong>, pid_max can be set to any value up to <code>2^22</code> (<code>PID_MAX_LIMIT</code>, approximately 4 million).</p>
<p>Source: <code>/proc/sys/kernel/pid_max</code></p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy">
<li>
<a href="https://github.com/thlorenz/procps/blob/master/index.js">index.js</a>
<span>, </span>
<a href="https://github.com/thlorenz/procps/blob/master/index.js#L401">lineno 401</a>
</li>
</ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>the number of digits in <code>PID_MAX</code></p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="sysinfo::getslabinfo"><span class="type-signature"></span>sysinfo::getslabinfo<span class="signature">()</span><span class="type-signature"> → {Array.<Object>}</span></h4>
</dt>
<dd>
<div class="description">
<p>Returns kernel slab allocator statistics.
Frequently used objects in the Linux kernel (buffer heads, inodes, dentries, * etc.) have their own cache.</p>
<p>For each slab cache, the cache name, the number of currently active objects,
the total number of available objects, the size of each object in bytes, the
number of pages with at least one active object, the total number of
allocated pages, and the number of pages per slab are given.</p>
<p><a href="http://linux.die.net/man/5/slabinfo">slabinfo man page</a></p>
<p>Source: <code>/proc/slabinfo</code></p>
<h5>NOTE</h5>
<p>Since <code>/proc/slabinfo</code> is only accessible to root, you need to run the process with <code>sudo</code> to access slabinfo.
It is therefore recommended to use this only when writing a script, <strong>please NEVER run your server as root!</strong></p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy">
<li>
<a href="https://github.com/thlorenz/procps/blob/master/index.js">index.js</a>
<span>, </span>
<a href="https://github.com/thloren