Skip to content

nghiattran/instance-stats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Get CPU and GPU statistics for Linux instances.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published