Created
September 10, 2019 08:55
-
-
Save buroz/e48861668ff70d0a4748d8d2024cbf0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const os = require("os"); | |
const delaySeconds = 1; | |
const decimals = 3; | |
(function loop() { | |
console.log("CPU load is " + cpuLoad()); | |
setTimeout(loop, delaySeconds * 1000); | |
})(); | |
function cpuLoad() { | |
let cpuLoad = os.loadavg()[0] * 100; | |
return cpuLoad.toFixed(decimals); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment