Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

instance-stats

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

instance-stats

Get CPU and GPU statistics for computer instances.

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 12 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc