Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何知道多核系统上的 CPU 使用率百分比。我使用 os npm 尝试了以下示例代码,但它没有返回我实际研究的结果。我期待结果类似于 linux top 命令。对此的任何帮助都会有所帮助。
setInterval(function() { os.cpuUsage(function(v){ console.log( 'CPU Usage (%): ' + v ); }); }, 1000 );
包os-utils只是一个从系统中获取一些数据的 API,你应该使用它来构建你的接口来获取类似于 Linux 中的 top 命令的东西。
os-utils
相反,如果您想要准备好使用的东西,您可以查看vtop完全符合您需要的包。
vtop
sudo npm install -g vtop vtop