Sunday, March 2, 2014

Node.js: get OS info

The Node.js core module "os" provide some info of the system operating system.

Here is example to list os info of Raspberry Pi, coded with Node.js.

Get os info in Node.js
Node.js to read OS info

var os= require("os");


console.log("os.tmpdir(): ", os.tmpdir());

console.log("os.endianness()= ", os.endianness());
console.log("os.hostname()= ", os.hostname());
console.log("os.type()= ", os.type());
console.log("os.platform()= ", os.platform());
console.log("os.arch(): ", os.arch());
console.log("os.release()= ", os.release());
console.log("os.uptime()= ", os.uptime());
console.log("os.loadavg()= ", os.loadavg());
console.log("os.totalmem()= ", os.totalmem());
console.log("os.freemem()= ", os.freemem());
console.log("os.cpus()= \n", os.cpus());
console.log("os.networkInterfaces()= \n", os.networkInterfaces());
console.log("os.EOL= ", os.EOL);

No comments: