Monday, 28 May 2018

006 Node.js OS Module

Node.js provides the basic information about the information of Operating system.

  • arch() : Returns a string identifying the  operating system CPU architecture.
  • constants : Returns an object containing the  commonly used operating system's constants for process signals.
  • cpus() : Returns an array of objects containing information about the computer CPU core.
  • endiannes() : Returns a string identifying the endianness of the CPU on which Node.js compiled.
  • EOL :  string constant defining  end-of-line marker for the current operating system.
  • freemem() : Returns the amount of free memory of the system.
  • hostname() : Returns the hostname of the operating system.
  • loadavg() : Returns an array containing the load averages, (1, 5, and 15 minutes).
  • networkInterfaces() : Returns the network interfaces that has a network address.
  • platform() : Returns information about the operating system's platform.
  • release() : Returns a string identifying information about the operating system's release.
  • tmpdir() : Returns the operating system's default directory for temporary files.
  • totalmem() : Returns the number of amount memory of the system.
  • type() : Returns a string identifying the operating system name.
  • uptime() : Returns the uptime of the operating system, in seconds.
  • userInfo() : Returns information about the current user.

Example 1
 const os=require('os');

console.log("os.os.arch(): \n",os.arch()); 

console.log("os.endianness(): \n",os.endianness()); 

console.log("os.freemem(): \n",os.freemem()); 

console.log("os.homedir(): \n",os.homedir()); 

console.log("os.hostname(): \n",os.hostname()); 

console.log("os.loadavg(): \n",os.loadavg());

console.log("os.platform(): \n",os.platform());

console.log("os.release(): \n",os.tmpdir());

console.log("os.platform(): \n",os.platform());

console.log("os.totalmem(): \n",os.totalmem());

console.log("os.type(): \n",os.type());

console.log("os.uptime(): \n",os.uptime());
 
Output :


os.os.arch():
 x64
os.endianness():
 LE
os.freemem():
 1696145408
os.homedir():
 C:\Users\dbhattacharjee
os.hostname():
 edmsws95
os.loadavg():
 [ 0, 0, 0 ]
os.platform():
 win32
os.release():
 C:\Users\DBHATT~1\AppData\Local\Temp
os.platform():
 win32
os.totalmem():
 4249927680
os.type():
 Windows_NT
os.uptime():
 461648 




Example 2

const os=require('os');
console.log("os.cpus(): \n",os.cpus());


Output :

os.cpus():
 [ { model: 'Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz',
    speed: 3093,
    times:
     { user: 53989468,
       nice: 0,
       sys: 17333000,
       idle: 390462515,
       irq: 379687 } },
  { model: 'Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz',
    speed: 3093,
    times:
     { user: 53434718,
       nice: 0,
       sys: 18220625,
       idle: 390129406,
       irq: 63562 } },
  { model: 'Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz',
    speed: 3093,
    times:
     { user: 46948515,
       nice: 0,
       sys: 17317781,
       idle: 397518453,
       irq: 54734 } },
  { model: 'Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz',
    speed: 3093,
    times:
     { user: 50369218,
       nice: 0,
       sys: 16611015,
       idle: 394804515,
       irq: 60406 } } ]











No comments:

Post a Comment

বাঙালির বেড়ানো সেরা চারটি ঠিকানা

  বাঙালি মানে ঘোড়া পাগল | দু একদিন ছুটি পেলো মানে বাঙালি চলল ঘুরতে | সে সমুদ্রই হোক , পাহাড়ি হোক বা নদী হোক। বাঙালির ...