Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.02k stars 2.59k forks source link

Monitoring : Cpu usage stuck at 0% even if real cpu usage is at ~30%-40% #4838

Open ouraios opened 3 years ago

ouraios commented 3 years ago

What's going wrong?

After updating to last pm2 version command pm2 ls display cpu at 0% usage but command pm2 monit display real cpu usage for ~30-40%

I use pm2-metrics which collect the 0% cpu from pm2 ls apparently.

How could we reproduce this issue?

Good question i dont know, for me it happened after updating pm2 to last version.

Supporting information

image image

--- PM2 report ----------------------------------------------------------------
Date                 : Thu Sep 03 2020 15:10:43 GMT+0200 (UTC+02:00)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.4.1
node version         : 14.4.0
node path            : /home/ouraios/.npm-packages/bin/pm2
argv                 : /usr/bin/node,/home/ouraios/.npm-packages/lib64/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : ouraios
uid                  : 1001
gid                  : 100
uptime               : 12min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.4.1
node version         : 14.4.0
node path            : /home/ouraios/.npm-packages/bin/pm2
argv                 : /usr/bin/node,/home/ouraios/.npm-packages/bin/pm2,report
argv0                : node
user                 : ouraios
uid                  : 1001
gid                  : 100
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Xeon(R) E-2136 CPU @ 3.30GHz
cpus nb              : 8
freemem              : 27916460032
totalmem             : 42949672960
home                 : /home/ouraios
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name           │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 1   │ API_PROD       │ default     │ 0.0.0   │ cluster │ 19615    │ 59s    │ 1    │ online    │ 47%      │ 287.6mb  │ ouraios  │ disabled │
│ 4   │ API_PROD       │ default     │ 0.0.0   │ cluster │ 19650    │ 57s    │ 1    │ online    │ 59.8%    │ 377.3mb  │ ouraios  │ disabled │
└─────┴────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
Module
┌────┬───────────────────────────────────────┬────────────────────┬───────┬──────────┬──────┬──────────┬──────────┬──────────┐
│ id │ module                                │ version            │ pid   │ status   │ ↺    │ cpu      │ mem      │ user     │
├────┼───────────────────────────────────────┼────────────────────┼───────┼──────────┼──────┼──────────┼──────────┼──────────┤
│ 5  │ pm2-metrics                           │ 1.0.38             │ 16739 │ online   │ 0    │ 0%       │ 60.0mb   │ ouraios │
└────┴───────────────────────────────────────┴────────────────────┴───────┴──────────┴──────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/home/ouraios/.pm2/pm2.log last 20 lines:
PM2        | 2020-09-03T14:57:55: PM2 log: App [API_PROD:1] starting in -cluster mode-
PM2        | 2020-09-03T14:57:55: PM2 log: App [API_PROD:1] onlinee-
PM2        | 2020-09-03T14:57:55: PM2 log: App [API_PROD:4] starting in -cluster mode-
PM2        | 2020-09-03T14:57:55: PM2 log: App [API_PROD:4] online
PM2        | 2020-09-03T14:57:55: PM2 log: App [pm2-metrics:5] starting in -fork mode-
PM2        | 2020-09-03T14:57:55: PM2 log: App [pm2-metrics:5] online
PM2        | 2020-09-03T15:09:44: PM2 log: App [API_PROD:1] starting in -cluster mode-
PM2        | 2020-09-03T15:09:44: PM2 log: App [API_PROD:1] online
PM2        | 2020-09-03T15:09:46: PM2 log: -reload- New worker listening
PM2        | 2020-09-03T15:09:46: PM2 log: Stopping app:API_PROD id:_old_1
PM2        | 2020-09-03T15:09:46: PM2 log: App name:API_PROD id:_old_1 disconnected
PM2        | 2020-09-03T15:09:46: PM2 log: App [API_PROD:_old_1] exited with code [0] via signal [SIGINT]
PM2        | 2020-09-03T15:09:46: PM2 log: pid=16610 msg=process killed
PM2        | 2020-09-03T15:09:46: PM2 log: App [API_PROD:4] starting in -cluster mode-
PM2        | 2020-09-03T15:09:46: PM2 log: App [API_PROD:4] online
PM2        | 2020-09-03T15:09:47: PM2 log: -reload- New worker listening
PM2        | 2020-09-03T15:09:47: PM2 log: Stopping app:API_PROD id:_old_4
PM2        | 2020-09-03T15:09:47: PM2 log: App name:API_PROD id:_old_4 disconnected
PM2        | 2020-09-03T15:09:47: PM2 log: App [API_PROD:_old_4] exited with code [0] via signal [SIGINT]
PM2        | 2020-09-03T15:09:48: PM2 log: pid=16643 msg=process killed
JAlbertoGonzalez commented 3 years ago

Same here. Since the last update, pm2 ls always shows cpu 0%.

But, if you type pm2 reset 99, the same table is shown with the correct value. So right now I'm using reset to see cpu usage.

I put "99" because it doesn't exists, so you will see Error: 99 id unkown, but the table will be shown anyway, without resetting anything.

I hope this issue is fixed soon.

alex-druzhinin commented 3 years ago

Hi, it's still here in version 4.5.6

Any thoughts when it would be fixed?

Samvith96 commented 1 year ago

Hi its still here in pm2 version 5.2.2 ubuntu 22.04 npm 6.14.17 node v14.21.1

Will this be fixed?

But, if you type pm2 reset 99, the same table is shown with the correct value. So right now I'm using reset to see cpu usage.

Thanks @JAlbertoGonzalez this helped me

sergio-domingues commented 11 months ago

Same here

DutchKevv commented 9 months ago

Bit off topic, sorry in advance:

But even Angular compiler process shows up with a max of 50MB memory usage, and for sure its a lot more. Anyone has the same problem with Mem: XXX usage instead of CPU, showing way to low value and never changing?

But other (NX) apps also never go above 50MB memory usage.. So it seems like PM2 is creating a fork or something, and only reads the parent cpu/memory usage.. Thats the feeling I get with this CPU/MEM issue

Thanks

marziale-n commented 5 months ago

Same here

cdll commented 1 month ago

same issue here with node@18.19.1 and pm2@5.3.1

olekolek1000 commented 1 month ago

Almost 4-year old issue, pm2 reset 999 is the only solution to properly show CPU usage. Wow.