doc-metrix-cpu
v0.0.1
Published
Provides an API for doc-metrix CPU performance metrics.
Downloads
2
Maintainers
Readme
doc-metrix-cpu
Provides an API for doc-metrix CPU performance metrics.
Installation
$ npm install doc-metrix-cpu
For use in the browser, use browserify.
Usage
To interface with the CPU metric documentation,
var metrics = require( 'doc-metrix-cpu' );
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( 'cpu.utilization' );
// returns true
metrics.mexists( 'mem.swapSpaceUtilization' );
// 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( /Guest/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 metric's documentation,
metrics.mget( 'cpu.utilization' );
// returns {...}
metrics.mget( 'mem.swapSpaceUtilization' );
// returns null
To return metric documentation matching a filter,
metrics.mget( /Guest/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( 'cpu0' );
// 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 metric 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( 'cpu0' );
// returns {"metric0":{...},"metric1":{...},...}
metrics.dget( 'eth0' );
// returns null
To return all devices and their associated 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
Copyright
Copyright © 2014. NodePrime.