doc-metrix-memory

0.0.2 • Public • Published

doc-metrix-memory

NPM version Build Status Coverage Status Dependencies

Provides an API for doc-metrix memory performance metrics.

Installation

$ npm install doc-metrix-memory

For use in the browser, use browserify.

Usage

To interface with the memory metric documentation,

var metrics = require( 'doc-metrix-memory' );

The interface has the following methods...

Metrics

Metric centric methods...

metrics.mexists( name )

Checks whether a metric having the provided name is included in the documentation.

metrics.mexists( 'mem.swapSpaceUtilization' );
// returns true

metrics.mexists( 'cpu.utilization' );
// returns false

Note: method is not case sensitive.

metrics.mlist()

Lists all metrics included in the documentation.

metrics.mlist();
// returns an array of metric names

metrics.mfilter( regexp )

Lists all metrics satisfying a regular expression filter.

metrics.mfilter( /active/i );

Note: filtering for metric names is case sensitive. Ignore case /i for case insensitive filtering.

metrics.mget( [filter] )

Returns metric documentation. The provided filter may be a string or a regular expression. If a metric does not have documentation, returns null. To return a single metric's documentation,

metrics.mget( 'mem.swapSpaceUtilization' );
// returns {...}

metrics.mget( 'cpu.utilization' );
// returns null

To return metric documentation matching a filter,

metrics.mget( /Active/i );
// returns {...}

To return all metric documentation,

metrics.mget();
// returns {"metric1":{...},"metric2":{...},...}

Note: when the filter is a string, the method is not case sensitive.

Note: when the filter is a regular expression, the method is case sensitive. If case does not matter, ignore case /i;

Devices

Device centric methods...

metrics.dexists( name )

Checks whether a device having the provided name is known to have associated metric documentation.

metrics.dexists( 'ram' );
// returns true

metrics.dexists( 'eth0' );
// returns false

metrics.dlist()

Lists all devices known to have associated metric documentation.

metrics.dlist();
// returns an array of device names

Note: the returned list may contain regular expressions. Regular expressions are included to account for platform variability.

metrics.dget( [name] )

Returns documentation associated with devices. If a device does not have associated metric documentation, returns null. To return a single device's metric documentation,

metrics.dget( 'ram' );
// returns {"metric0":{...},"metric1":{...},...}

metrics.dget( 'eth0' );
// returns null

To return all devices and their associated metric documentation,

metrics.dget();
// returns {"device0":{...},"device1":{...},...}

Examples

To run the example code from the top-level application directory,

$ node ./examples/index.js

Notes

After running the following commands,

$ npm install
$ npm update

this package, when used as a dependency, will attempt an HTTP request to retrieve the latest documentation from Github.

During development, run the following command to retrieve the latest documentation

$ npm run docs

Tests

Unit

Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:

$ make test

All new feature development should have corresponding unit tests to validate correct functionality.

Test Coverage

This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

$ make test-cov

Istanbul creates a ./reports/coverage directory. To access an HTML version of the report,

$ open reports/coverage/lcov-report/index.html

License

MIT license.


Copyright

Copyright © 2014. NodePrime.

Package Sidebar

Install

npm i doc-metrix-memory

Weekly Downloads

1

Version

0.0.2

License

none

Last publish

Collaborators

  • kgryte