Convert the output of os.cpus() in Node.js to percentage

后端 未结 8 1611
伪装坚强ぢ
伪装坚强ぢ 2020-12-08 11:27

Is there a way to convert the os.cpus() info to percentage? Just like the output of iostat (on the CPU section).

My code:

var os = require(\'os\');
c         


        
8条回答
  •  粉色の甜心
    2020-12-08 11:51

    This module, that caN be installed using NPM provides what you need:

    https://github.com/oscmejia/os-utils

    calle the cpuUsage(callback) method and you will get what you need.

提交回复
热议问题