OS Module

// import node module
var os = require('os');

var gigabyte = 1 / Math.pow(1024,3);

// show memory information of the laptop

console.log('Total RAM / memory: ' + os.totalmem()*gigabyte + ' GBs');
console.log('Free RAM / memory: ' + os.freemem()*gigabyte + ' GBs');
console.log('Consumed precentage: ' + ((os.totalmem() - os.freemem())/os.totalmem())*100);

// show CPU information

console.log('This laptop has ' + os.cpus().length + ' CPUs.');


Comments

Popular posts from this blog

Lesson 2 Chat

Arrays