https://github.com/jdforsythe/cpu-pct
Node module to get the current CPU usage in percent
https://github.com/jdforsythe/cpu-pct
cpu cpu-pct node node-js node-module nodejs percent
Last synced: 5 months ago
JSON representation
Node module to get the current CPU usage in percent
- Host: GitHub
- URL: https://github.com/jdforsythe/cpu-pct
- Owner: jdforsythe
- Created: 2016-07-09T16:20:47.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-07-09T16:52:29.000Z (over 9 years ago)
- Last Synced: 2025-08-09T03:49:14.048Z (5 months ago)
- Topics: cpu, cpu-pct, node, node-js, node-module, nodejs, percent
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cpu-pct
Node module to get the current CPU usage in percent. This uses the `os` module and has no outside dependencies.
This function gets the CPU percentage _once_ and does not continue returning values.
# Install
```sh
$ npm install --save cpu-pct
```
# Usage
```js
const cpu = require('cpu-pct');
const options = {
interval: 100, // time span to get average percent usage (in milliseconds)
returnType: "string", // "fraction", "whole", or "string"
decimals: 2
};
cpu.cpuPercent(options, function(pct) {
console.log(pct);
});
```