OS Node.js提供了一些基本的底層操作系統的模塊 "OS" . API ...
OS
Node.js提供了一些基本的底層操作系統的模塊OS.
API
var os = require('os');
console.log('[arch] 操作系統CPU架構'+os.arch());
console.log('[cpus] 每個CPU/內核的信息:'+JSON.stringify(os.cpus()));
console.log('[endianness] CPU 的位元組序:'+os.endianness());
console.log('[freemem] 操作系統空閑記憶體量:'+os.freemem());
console.log('[homedir] 當前用戶使用的文件夾:'+os.homedir());
console.log('[hostname] 操作系統的主機名:'+os.hostname());
console.log('[loadavg] 平均負載:'+os.loadavg());
console.log('[networkInterfaces] 網路介面:'+JSON.stringify(os.networkInterfaces()));
console.log('[platform] 操作系統名:'+os.platform());
console.log('[release] 操作系統的發行版本:'+os.release());
console.log('[tmpdir] 操作系統的預設臨時文件夾:'+os.tmpdir());
console.log('[totalmem] 系統記憶體總量:'+os.totalmem());
console.log('[type] 操作系統名:'+os.type());
console.log('[uptime] 操作系統運行的時間:'+os.uptime());
[arch] 操作系統CPU架構x64
[cpus] 每個CPU/內核的信息:[{"model":"Intel(R) Core(TM) i5-4200H CPU @ 2.80GHz","speed":2794,"times":{"user":12349500,"nice":0,"sys":13773515,"idle":76721437,"irq":1744218}},{"model":"Intel(R) Core(TM) i5-4200H CPU @ 2.80GHz","speed":2794,"times":{"user":12447781,"nice":0,"sys":11801625,"idle":78594843,"irq":320156}},{"model":"Intel(R) Core(TM) i5-4200H CPU @ 2.80GHz","speed":2794,"times":{"user":13889359,"nice":0,"sys":12343843,"idle":76611046,"irq":141578}},{"model":"Intel(R) Core(TM) i5-4200H CPU @ 2.80GHz","speed":2794,"times":{"user":12556328,"nice":0,"sys":11338265,"idle":78949640,"irq":128375}}]
[endianness] CPU 的位元組序:LE
[freemem] 操作系統空閑記憶體量:2904788992
[homedir] 當前用戶使用的文件夾:C:\Users\Administrator
[hostname] 操作系統的主機名:SKYUSER-9PEIINO
[loadavg] 平均負載:0,0,0
[networkInterfaces] 網路介面:{"VMware Network Adapter VMnet1":[{"address":"xxxxxxxxxxx","netmask":"ffff:ffff:ffff:ffff::","family":"IPv6","mac":"00:50:56:c0:00:01","scopeid":21,"internal":false},{"address":"192.168.80.1","netmask":"255.255.255.0","family":"IPv4","mac":"00:50:56:c0:00:01","internal":false}],"VMware Network Adapter VMnet8":
.......,"scopeid":0,"internal":false},{"address":"fe80::8cd:96a1:2214:bcfb","netmask":"ffff:ffff:ffff:ffff::","family":"IPv6","mac":"00:00:00:00:00:00","scopeid":8,"internal":false}]}
[platform] 操作系統名:win32
[release] 操作系統的發行版本:10.0.10240
[tmpdir] 操作系統的預設臨時文件夾:C:\Users\ADMINI~1\AppData\Local\Temp
[totalmem] 系統記憶體總量:8473526272
[type] 操作系統名:Windows_NT
[uptime] 操作系統運行的時間:501123.2912315