[英]How to get CPU usage on a multi core system
How to know the CPU usage in percentage on multi core system. 如何知道多核系统上的CPU使用率百分比。 I tried the below sample code using os npm but it does not return the result what I am actually looking into it.
我使用os npm尝试了以下示例代码,但它没有返回我实际正在研究的结果。 I am expecting the result something similar to linux top command.
我期望结果类似于linux top命令。 Any help on this will be helpful.
对此的任何帮助将是有帮助的。
setInterval(function() {
os.cpuUsage(function(v){
console.log( 'CPU Usage (%): ' + v );
});
}, 1000 );
Package os-utils
is only an API to get some data from the system, you should build your interface using it to obtain something like a top command in Linux. 软件包
os-utils
只是一个从系统中获取一些数据的API,您应该使用它来构建您的界面,以获取类似于Linux中的top命令之类的东西。
Instead if you want something ready to be used you can take a look at vtop
package that does exactly what you need. 相反,如果您希望可以使用某些东西,可以看一下
vtop
您所需的vtop
软件包。
sudo npm install -g vtop
vtop
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.