procps-ticker

0.2.0 • Public • Published

procps-ticker build status

Ticks proc info of the host machine at given intervals and exposes it via a stream interface.

var getstat = require('procps-ticker').sysinfo.getstat;
 
function pad(s) {
  return String('          ' + s).slice(-10);
}
 
function end(stream) {
  stream.end();
  console.error('\nending');
}
 
var stream = getstat({ interval: 500 })
stream
  .on('error', console.error)
  .once('data', function (d) { 
    var keys = Object.keys(d).map(function (k) { return pad(k) }).join('');
    process.stdout.write(keys + '\n');
  })
  .on('data', function (d) {
    var vals = Object.keys(d).map(function (k) { return pad(d[k]) }).join('')
    process.stdout.write(vals + '\r');
  })
 
 
setTimeout(end, 10000, stream);

procps-ticker

Table of Contents generated with DocToc

Installation

npm install procps-ticker

API

procps

Exposes the underlying procps library in order to allow calling methods on it directly.

Source:

readproctab(opts) → {ReadableStream}

Creates a stream that will emit readprocdata at the given interval.

Parameters:
Name Type Description
opts Object

options

Properties
Name Type Argument Description
interval number <optional>

interval in milliseconds at which to emit data (default: 1000ms)

flags number <optional>

readproc flags

Source:
Returns:

stream that emits readproctab data at the given interval

Type
ReadableStream

Stream::end()

Call this on any of the returned streams in case you want to tell the state stream to end. Useful for testing and/or when you want to end your debugging session and allow the program to exit.

Source:

sysinfo::getdiskstat(opts) → {ReadableStream}

Creates a stream that will emit disk stats at the given interval.

Parameters:
Name Type Description
opts Object

options

Properties
Name Type Argument Description
interval number <optional>

interval in milliseconds at which to emit data (default: 1000ms)

Source:
Returns:

stream that emits disk stats at the given interval

Type
ReadableStream

sysinfo::getstat(opts) → {ReadableStream}

Creates a stream that will emit stats at the given interval.

Parameters:
Name Type Description
opts Object

options

Properties
Name Type Argument Description
interval number <optional>

interval in milliseconds at which to emit data (default: 1000ms)

Source:
Returns:

stream that emits stats at the given interval

Type
ReadableStream

sysinfo::loadavg(opts) → {ReadableStream}

Creates a stream that will emit loadavg info at the given interval.

Parameters:
Name Type Description
opts Object

options

Properties
Name Type Argument Description
interval number <optional>

interval in milliseconds at which to emit data (default: 1000ms)

Source:
Returns:

stream that emits loadavg info at the given interval

Type
ReadableStream

sysinfo::meminfo(opts) → {ReadableStream}

Creates a stream that will emit meminfo at the given interval.

Parameters:
Name Type Description
opts Object

options

Properties
Name Type Argument Description
interval number <optional>

interval in milliseconds at which to emit data (default: 1000ms)

unit number <optional>

'b'|'k'|'m'|'g' to return usage in Bytes|KB|MB|GB respectively

Source:
Returns:

stream that emits meminfo at the given interval

Type
ReadableStream

sysinfo::uptime(opts) → {ReadableStream}

Creates a stream that will emit uptime info at the given interval.

Parameters:
Name Type Description
opts Object

options

Properties
Name Type Argument Description
interval number <optional>

interval in milliseconds at which to emit data (default: 1000ms)

Source:
Returns:

stream that emits uptime info at the given interval

Type
ReadableStream

sysinfo::uptimeSince(opts) → {ReadableStream}

Creates a stream that will emit uptime since info at the given interval.

Parameters:
Name Type Description
opts Object

options

Properties
Name Type Argument Description
interval number <optional>

interval in milliseconds at which to emit data (default: 1000ms)

Source:
Returns:

stream that emits uptime since info at the given interval

Type
ReadableStream

sysinfo::vminfo(opts) → {ReadableStream}

Creates a stream that will emit vminfo at the given interval.

Parameters:
Name Type Description
opts Object

options

Properties
Name Type Argument Description
interval number <optional>

interval in milliseconds at which to emit data (default: 1000ms)

Source:
Returns:

stream that emits vminfo at the given interval

Type
ReadableStream

generated with docme

License

MIT

Package Sidebar

Install

npm i procps-ticker

Weekly Downloads

0

Version

0.2.0

License

MIT

Last publish

Collaborators

  • thlorenz