instance-stats

0.0.4 • Public • Published

instance-stats

NPM version Build Status Dependency Status Coverage percentage

Installation

  npm install --save instance-stats

Usage

Basics

const instanceStats = require('instance-stats');
 
// Get cpu info
let cpus = instanceStats.getCpuInfo();
console.log(cpus);
 
// Get gpu info. getGpusInfo function return a promise
instanceStats.getGpusInfo()
  .then(function(gpus, stderr) {
    console.log(gpus);
  })
  .catch(function(error) {
    console.log(error);
  })

Usage observer

This library also provide Observer object for getting CPU and GPU usage.

const instanceStats = require('instance-stats');
 
// Create an observer object which broadcasts infomation every second (1000ms)
const observer = new instanceStats.StatsObserver(1000);
 
// Listen on CPU event
observer.on('cpu', function(cpuInfo, timestamp) {
  // Do something...
});
 
// Listen on GPU event
observer.on('gpu', function(cpuInfo, timestamp) {
  // Do something...
});
 
// Listen on GPU error event
observer.on('gpu-error', function(error) {
  // Do something...
});
 
// Start the observer
observer.start();
 
// Stop the observer after 5 seconds (5000ms)
setTimeout(function () {
  observer.stop();
}, 5000);

Getting To Know Yeoman

Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced. Feel free to learn more about him.

Created with

Yeoman and Generator-simple-package

License

MIT © nghiattran

Readme

Keywords

none

Package Sidebar

Install

npm i instance-stats

Weekly Downloads

1

Version

0.0.4

License

MIT

Last publish

Collaborators

  • nghiattran