Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High CPU usage #3027

Open
burgerga opened this issue Nov 21, 2024 · 6 comments
Open

High CPU usage #3027

burgerga opened this issue Nov 21, 2024 · 6 comments

Comments

@burgerga
Copy link

Check the bug
Previous issues were closed as solved

Describe the bug
Instead of <5% CPU Usage, I have around 15-25% CPU usage for glances on a Intel Core i3-8100T (running Proxmox)

To Reproduce
Steps to reproduce the behavior:

  1. Install glances on Proxmox using https://raw.githubusercontent.com/nicolargo/glancesautoinstall/master/install.sh (via https://community-scripts.github.io/ProxmoxVE/scripts?id=glances)
  2. Start via systemd service (/usr/local/bin/glances -w)
  3. Open glances website
  4. Observe high CPU

Expected behavior
Observe low CPU

Screenshots
image

Environement (please complete the following information)

  • Operating System (lsb_release -a or OS name/version):
    Proxmox:
    Distributor ID: Debian
    Description:    Debian GNU/Linux 12 (bookworm)
    Release:        12
    Codename:       bookworm
    
  • Glances & psutil versions:
    Glances version:        4.2.1
    Glances API version:    4
    PsUtil version:         5.9.4
    Log file:               /root/.local/share/glances/glances.log
    
  • How do you install Glances (Pypi package, script, package manager, source): https://raw.githubusercontent.com/nicolargo/glancesautoinstall/master/install.sh
  • Glances test:
    glances_issue.txt

Additional context
I have around 30 LXCs running in proxmox, so the processlist is quite long.
How can I further debug this?

You can also pastebin:

@burgerga
Copy link
Author

burgerga commented Nov 21, 2024

Well, I guess this is indeed part of the problem:

processcount  [OK]    0.24868s
{'pid_max': 0, 'running': 1, 'sleeping': 922, 'thread': 2347, 'total': 1091}

But I also get high CPU if I request only CPU and MEM use using the gethomepage.dev glances info widget

@nicolargo
Copy link
Owner

Strange, Glances is now optimzed for CPU consumption (on my PC, it consume ~5% CPU).

Can you try this:

glances --disable-plugin all --enable-plugin quicklook,cpu,mem,swap,load,processlist

@burgerga
Copy link
Author

Then it's between 8-15%, but mostly around 10%. If I remove processlist, and use top in a different shell I can see it does 3%.

@burgerga
Copy link
Author

burgerga commented Nov 24, 2024

Apart from opening the website, I also tried using the API by using the homepage widget, which doesn't use the processlist endpoint (see https://github.com/gethomepage/homepage/blob/a06964dd175fa798fa9189ba1ecd5766bbde543f/src/pages/api/widgets/glances.js) but still causes high cpu... is this triggered by accessing the API?

@nicolargo
Copy link
Owner

nicolargo commented Nov 27, 2024

You can also try to limit the number of processes to display in the WebUI.

In the glances.conf file:

[outputs]
...
# Limit the number of processes to display (in the WebUI)
max_processes_display=25
...

Yes for the moment, Glances update all plugins when a call is done to the API (but limited at one update every time). An optimisation can be discussed on this point but it is not straighforward because plugins can be linked (for example processlist and alert). I just open an issue to follow this specific point: #3033

@burgerga
Copy link
Author

Hmm, that doesn't seem to matter very much, it's still around 20%.

However your linked issue is what I suspected. As a temporary workaround I now started a separate glances with:

glances --disable-plugin all --enable-plugin cpu,mem,fs,load,uptime,sensors -p 61209 -w --disable-webui

and connected it to my dashboard. It's now working perfectly with 0-3% CPU, and I can still access the cpu-hungry web interface at 61208 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants