nodejs electron 实时监控系统上所有进程信息 开源
地址:https://www.npmjs.com/package/node-process-watcher。仅使用非常小的资源消耗。
·
地址:https://www.npmjs.com/package/node-process-watcher
仅使用非常小的资源消耗。
const {node_process_watcher} = require("node-process-watcher");
// or import {node_process_watcher} from "node-process-watcher";
node_process_watcher.on("screen1",(list)=>{
// Print the information of all processes on the system every second
// 每秒打印一次系统上所有进程的信息
console.log(list[0]);
// { id: 4, user_name: 'SYSTEM', cpu: 0, mem: 0, name: 'System' }
node_process_watcher.close("screen1"); // 关闭
})
node_process_watcher.on("screen2",(list)=>{
// Filter specific processes
// 过滤特定的进程
node_process_watcher.pids("screen2",[
list[0].id
])
console.log(list[0]);
if (list.length === 1) {
// Stop listening for information only after all the on events are closed
// 所有的on关闭后才会停止监听信息上的信息
node_process_watcher.close("screen2");
}
})

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。
更多推荐
所有评论(0)