pm2-perfmonitor 2.3.0 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/app.js CHANGED
@@ -198,9 +198,11 @@ const processChecker = async () => {
198
198
  const { name, pid, pm_id, monit, pm2_env } = app
199
199
 
200
200
  const sysCpuUsage = await getSysCpuUsageByPid(pid)
201
+ const pm2CpuUsage = monit?.cpu
201
202
 
202
203
  const appStatus = pm2_env?.status
203
- const appCpuUsage = sysCpuUsage
204
+ const appCpuUsage =
205
+ typeof sysCpuUsage === 'number' ? sysCpuUsage : pm2CpuUsage
204
206
 
205
207
  // 非目标应用,跳过
206
208
  if (
package/lib/utils.js CHANGED
@@ -45,9 +45,12 @@ const sleepAsync = (duration = 0) => {
45
45
  * @returns { Promise<number> } CPU 使用率
46
46
  */
47
47
  const getSysCpuUsageByPid = async (pid) => {
48
- const stats = await pidusage(pid)
49
-
50
- return stats.cpu
48
+ try {
49
+ const stats = await pidusage(pid)
50
+ return stats.cpu
51
+ } catch (err) {
52
+ console.error('Call pidusage error:', err)
53
+ }
51
54
  }
52
55
 
53
56
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pm2-perfmonitor",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
4
4
  "description": "A pm2 module for performance monitoring. Automatically detect zombie processes and restart it",
5
5
  "author": {
6
6
  "name": "elenh",