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

Wrong (?) cpu use reported in web interface #3261

Open
squalou opened this issue Feb 24, 2025 · 6 comments
Open

Wrong (?) cpu use reported in web interface #3261

squalou opened this issue Feb 24, 2025 · 6 comments

Comments

@squalou
Copy link

squalou commented Feb 24, 2025

Versions

  • Core version is v6.0.3 (Latest: v6.0.4)
  • Web version is v6.0.1 (Latest: v6.0.1)
  • FTL version is v6.0.2 (Latest: v6.0.2)

Platform

PRETTY_NAME="Raspbian GNU/Linux 12 (bookworm)"
NAME="Raspbian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=raspbian
ID_LIKE=debian


Linux pihole 6.6.31+rpt-rpi-v6 #1 Raspbian 1:6.6.31-1+rpt1 (2024-05-29) armv6l GNU/Linux

Expected behavior

In web UI, there's a "status" area with memory and CPU use displayed.

Since v6, I'm alarmed at CPU figure, and indeed there was an issue (solved after reading another post).

YET : the CPU figure is totally off compared to 'top' or 'htop' figure reported at the same time over ssh.

I would expect the figure to reflect more the reality, it was the case with v5

Actual behavior / bug

When logging into web UI, CPU use display is between 40 and 50%.

It may go down / go up for no reason.

At the same time, under an ssh session, reported CPU use is as follow :

most of the time :

Image

during a momentary peak :

Image

Steps to reproduce

Steps to reproduce the behavior:

  1. Go to admin web UI and log in
  2. Look at CPU status on top left corner

Debug Token

  • URL:

https://tricorder.pi-hole.net/HjxwOLwp/

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

@yubiuser yubiuser transferred this issue from pi-hole/pi-hole Feb 24, 2025
@DL6ER
Copy link
Member

DL6ER commented Feb 24, 2025

Are you running your Pi-hole "bare metal" or inside some sort of virtualized environment? In case of the latter, it is known (especially for LXC) that the kernel is reporting partially incorrect numbers to the virtualized applications, e.g., the cores allocated to the container but then the load of the entire system.

Something definitely seems off on your system as the debug log says:

*** [ DIAGNOSING ]: Core version
git status failed

*** [ DIAGNOSING ]: Web version
git status failed

Did you run pihole -d with sudo ?

@squalou
Copy link
Author

squalou commented Feb 25, 2025

Hi,
thank you for answering, and please forgive me indeed looks likes I forgot sudo.
doing it again.

(dont be surprised if diagnosis report issues with ipv6 : I've disabled it on my gateway for some reasons)

https://tricorder.pi-hole.net/q3dwg124/

should be better now :

*** [ DIAGNOSING ]: Web version
[✓] Version: v6.0.1
[i] Remotes: origin	https://github.com/pi-hole/web.git (fetch)
             origin	https://github.com/pi-hole/web.git (push)
[i] Branch: master
[i] Commit: v6.0.1-0-g42e7279

I'm running Pi-Hole on a Raspberry Pi Zero 2W. Reporting used to be fine before 6 update.

Note that I've noticed that displayed value in UI tends to 'lower' over time, but always stays an order of magnitude over what 'top' reports. I wonder if there's a kind of 'averaging' that happens, and maybe CPU really goes up on login, which would make the average wrong.

@DL6ER
Copy link
Member

DL6ER commented Feb 25, 2025

Could you please share the outputs of the following commands?

pihole api info/system
nproc
uptime

ideally at the same time

@squalou
Copy link
Author

squalou commented Feb 26, 2025

Sure,

doing it again with a top at the same time too,

~ $ nproc
1
[1] 24931
 09:05:08 up 2 days, 26 min,  2 users,  load average: 0,13, 0,14, 0,11
pihole@pihole:~ $ API Authentication: Trying to use CLI password
API Authentication: Success

Requesting: GET http://localhost:80/api/info/system

Status: 200
Data:
{
  "system": {
    "uptime": 174423,
    "memory": {
      "ram": {
        "total": 438156,
        "free": 86664,
        "used": 78560,
        "available": 302412,
        "%used": 17.929687143391853
      },
      "swap": {
        "total": 204796,
        "free": 203772,
        "used": 1024,
        "%used": 0.5000097658157386
      }
    },
    "procs": 115,
    "cpu": {
      "nprocs": 1,
      "load": {
        "raw": [
          0.12841796875,
          0.1396484375,
          0.10791015625
        ],
        "percent": [
          12.841796875,
          13.96484375,
          10.791015625
        ]
      }
    }
  },
  "took": 0.000676870346069336
}
API Logout: Success (session deleted)

top - 09:05:16 up 2 days, 27 min,  2 users,  load average: 0,15, 0,15, 0,11
Tasks:  87 total,   1 running,  86 sleeping,   0 stopped,   0 zombie
%Cpu(s):  2,3 us,  1,6 sy,  0,0 ni, 96,1 id,  0,0 wa,  0,0 hi,  0,0 si,  0,0 st 
MiB Mem :    427,9 total,     84,6 free,    132,6 used,    266,5 buff/cache     
MiB Swap:    200,0 total,    199,0 free,      1,0 used.    295,3 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                           
  504 pihole    10 -10   23868  19784   9064 S   2,0   4,5  60:44.74 pihole-FTL                                        
24896 pihole    20   0   12144   4664   2724 R   1,6   1,1   0:01.29 top                                               
    1 root      20   0   35772  10268   8084 S   0,0   2,3   0:39.25 systemd                                           
    2 root      20   0       0      0      0 S   0,0   0,0   0:00.12 kthreadd    

I would say that load average seem consistent (I re lauched several time, uptime / top / load:raw form the API are all coherent). Top

load average: 0,13, 0,14, 0,11

But that's a weird load, probably average is 'higher' that cpu use due to recurrent tasks running ?

When I run pihole api info/system, of course I can see the pihole-FTL process goes up to 60% CPU, but that does not explain the 0,11 on average over 15 minutes.

I also checked Web UI : the value displayed is consistent with the load average

A sort-of explanation would be that when displayed, gathering the load information itself causes the cpu to work which would cause increase reported value ? (considering a Pi Zero has not much power available)

I've checked an old screenshot and ... I'm probably misled too by the fact that previously, the LOAD was displayed,
and now it's displayed as "CPU percent"

Image

So,

all in all I would say that

  • figures now are multiplied by 100 ,not load average => explains why I was surprised by the value
  • login in to web UI causes CPU to work, hence causes load average over a minute to go up
  • leaving things running seems good, here's what is displayed :
    • CPU: 4.7 % a few moments ago, after leaving the page open but unseen
    • CPU: 15.9 % right now after looking at it :)

Good news is : after all, things look to work fine provided I just leave it alone. (which I usually do: ) )

I still would suggest some UI change for clarity

  • display "load" when figures are "load"
  • display CPU if ever the numbers come from usual CPU figures

I mean, for instance here : load average is 17%, but CPU use is 3% ( 100 - 97 idle ).

top - 09:28:14 up 2 days, 50 min,  2 users,  load average: 0,17, 0,17, 0,12
Tasks:  87 total,   1 running,  86 sleeping,   0 stopped,   0 zombie
%Cpu(s):  3,0 us,  0,0 sy,  0,0 ni, 97,0 id,  0,0 wa,  0,0 hi,  0,0 si,  0,0 st 

I don't know if getting the CPU use value is doable, but renaming load to CPU does not seem right.

@DL6ER
Copy link
Member

DL6ER commented Feb 26, 2025

Good news is : after all, things look to work fine provided I just leave it alone. (which I usually do: ) )

👍

I don't know if getting the CPU use value is doable, but renaming load to CPU does not seem right.

Yes, I guess you are right. Load is actually a (much!) better metric than CPU%. True, the latter may be more intuitive but the load is what actually matters. If there is heavy I/O load, this may affect your system in a bad way, slowing it down to a crawl. CPU% may be low at the same time not providing you with the necessary information that something is off here.

@DL6ER DL6ER transferred this issue from pi-hole/FTL Feb 26, 2025
@DL6ER
Copy link
Member

DL6ER commented Feb 27, 2025

See #3262 in combination with pi-hole/FTL#2297

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