node.js - 获取 Windows 和 Nodejs 上的 CPU 使用百分比
问题描述
我正在尝试获取 Windows 中的处理器使用百分比,我目前有以下代码:
const usage = process.cpuUsage();
const currentCPUUsage = (usage.user + usage.system) * 1000;
const percentCpu = currentCPUUsage / total * 100;
console.log(`El totoal: ${total}, cpu_user: ${usage.user}, cpu_system: ${usage.system}`)
但它并没有给我带来总百分比,我希望得到 Windows 任务管理器中显示的百分比。
知道我能做什么吗?
谢谢。
解决方案
推荐阅读
- node.js - 特定弹性 beanstalk 环境的应用程序部署显示运行状况下降
- node.js - Node.JS 使用 MD5 / ECB 和使用 PKCS7 的填充进行加密
- r - as.coded.data 函数不会用变量代替 R 中的数字
- excel - 用于 Netflix 观看活动标题的正则表达式(使用“剧集”的电视节目与电影)
- html - Flexbox 内容响应式网格行
- sql - FCFG SQL 查询,无法生成 AND 查询
- c# - 方法本身使用工厂方法创建类时的模拟测试场景
- angular - 显示 html 内容的 Angular 表单
- sql - 根据 SQL 中的另一列获取最大日期
- amazon-web-services - 在 AWS 上设置 jfrog artifactory pro 的具体步骤是什么?