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

Sensors plugin generates a peak of CPU consumption #2851

Open
nicolargo opened this issue Jun 23, 2024 · 3 comments
Open

Sensors plugin generates a peak of CPU consumption #2851

nicolargo opened this issue Jun 23, 2024 · 3 comments

Comments

@nicolargo
Copy link
Owner

nicolargo commented Jun 23, 2024

  1. Run Glances with the sensor plugin enabled: every 3 refreshs a peak of Glances process CPU is observed.
  2. Run Glances with the sensor plugin disabled: no CPU peak observed.

Note: the peak every "3 refreshs" is related to the following key in the sensors code:

# Define the default refresh multiplicator
# Default value is 3 * Glances refresh time
# Can be overwritten by the refresh option in the sensors section of the glances.conf file
DEFAULT_REFRESH = 3

The goal is to understand why the CPU peak is so high (from 5% to 11% on my system).

@nicolargo nicolargo added this to the Glances 4.1.0 milestone Jun 23, 2024
@nicolargo
Copy link
Owner Author

nicolargo commented Jun 23, 2024

A specific branch (issue2851) has been created with a specific test script (test-data/issues/issue2851.py):

./venv/bin/python ./test-data/issues/issue2851.py 
Init Glances to make the stats more relevant (wait 6 seconds)
CPU consumption with sensors plugin disable
1/6: 0 sensor
2/6: 0 sensor
3/6: 0 sensor
4/6: 0 sensor
5/6: 0 sensor
6/6: 0 sensor
CPU consumption with sensors plugin disable: 5.8
CPU consumption with sensors plugin enable
1/6: 9 sensors
2/6: 9 sensors
3/6: 9 sensors
4/6: 9 sensors
5/6: 9 sensors
6/6: 9 sensors
CPU consumption with sensors plugin enable: 8.3

@nicolargo
Copy link
Owner Author

nicolargo commented Jun 23, 2024

After a quick analyse, the peak (between 2 and 3% of a CPU core) came from the calls to psutil.sensors_temperatures() and psutil.sensors_fans().

@eric72777
Copy link

I don't know if it's related to this issue, but I noticed significantly higher CPU usage on recent versions of glances.

I've noticed this on multiple machines, but it's currently running on Docker version 25.0.6.

Old version with good CPU usage:

  glances:
    container_name: glances
    environment:
      - GLANCES_OPT=-w --disable-check-update --time 2 --disable-plugin amps,containers,processcount
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    pid: host
    network_mode: host
    image: docker.io/nicolargo/glances:3.4.0.5-full
    restart: unless-stopped

Newer version with high CPU usage:

  glances:
    container_name: glances
    environment:
      - GLANCES_OPT=-w --disable-check-update --time 2 --disable-plugin amps,containers,processcount
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    pid: host
    network_mode: host
    image: docker.io/nicolargo/glances:latest #4.1.2.1
    restart: unless-stopped

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