Skip to content

Instantly share code, notes, and snippets.

@GaetanoPiazzolla
GaetanoPiazzolla / avgLoad.js
Last active October 28, 2024 22:00
% CPU in Node.JS
const os = require("os");
//Create function to get CPU information
function cpuAverage() {
//Initialise sum of idle and time of cores and fetch CPU info
var totalIdle = 0, totalTick = 0;
var cpus = os.cpus();
//Loop through CPU cores