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

Cannot show the CPU usages of the processes #135

Closed
Tigerfyj opened this issue Jun 10, 2020 · 28 comments
Closed

Cannot show the CPU usages of the processes #135

Tigerfyj opened this issue Jun 10, 2020 · 28 comments
Assignees
Labels
bug Something isn't working needs:question Further information is requested os:linux
Milestone

Comments

@Tigerfyj
Copy link

gotop version:

gotop v4.0.1 (20200609T145934)

OS/Arch:

4.19.118-v7+ GNU/Linux

Terminal emulator:

iTerm on Mac, ssh to Raspberry Pi.

Any relevant hardware info:

Raspberry Pi B3+, Raspberry Pi B4

tmux version:

tmux 2.8

In the process widget, all cpu usages are 'NaN' or '+Inf'. I also tried to run with sudo, the output was same. Attached a screenshot.

Screen Shot 2020-06-10 at 11 18 31 PM

@Tigerfyj
Copy link
Author

The content of ~/.local/state/gotop/errors.log

00:04:54 cpu.go:102: error: number of CPU usage percents from gopsutil doesn't match CPU count. percents: [7.000000000061846 6.999999999608917 1.0101010100866268 9.99999999994543]. self.Count: 0
00:04:55 cpu.go:102: error: number of CPU usage percents from gopsutil doesn't match CPU count. percents: [0 7.216494845585563 5.999999999994543 0]. self.Count: 0

@xxxserxxx
Copy link
Owner

@Tigerfyj , a Raspberry, huh? What's the architecture on that? Can you please provide the output for:

  • arch, or uname -m
  • ps -axo pid:10,comm:50,pcpu:5,pmem:5 | head -n 5
  • cat /etc/lsb-release

That last command varies by distribution, but if you can find an lsb-* file somewhere in /etc/ that's what I'm looking for.

@xxxserxxx xxxserxxx added bug Something isn't working needs:question Further information is requested os:linux labels Jun 11, 2020
@Tigerfyj
Copy link
Author

Tigerfyj commented Jun 11, 2020

$ uname -m
armv7l

$ ps -axo pid:10,comm:50,pcpu:5,pmem:5 | head -n 5
       PID COMMAND                                             %CPU  %MEM
         1 systemd                                              0.0   0.5
         2 kthreadd                                             0.0   0.0
         3 rcu_gp                                               0.0   0.0
         4 rcu_par_gp                                           0.0   0.0

$ sudo find /etc -name '*lsb*'
(empty)

@Tigerfyj
Copy link
Author

I use 'arm6' version of the binary. I just tried the version 3.5.0 and it works well.

@xxxserxxx
Copy link
Owner

That's interesting and useful to know, thank you.

@xxxserxxx
Copy link
Owner

@Tigerfyj everything looks OK, so can you provide a little more information? If you run:

gotop --list paths

the very last line points to the log file. It may not be the same as the .local/state/gotop/errors.log path. Can you please confirm that you found the right log file, and if it's different, can you post the output from that log file?

Thanks!

@xxxserxxx xxxserxxx added this to the v4.0.2 milestone Jun 12, 2020
@xxxserxxx xxxserxxx self-assigned this Jun 12, 2020
@Tigerfyj
Copy link
Author

I downloaded v4.0.1 again and run it multiple times today. But, the errors.log is empty now.

$ gotop -V
gotop v4.0.1 (20200609T145934)
$ gotop --list paths
Loadable colorschemes & layouts, and the config file, are searched for, in order:
/home/pi
/home/pi/.config/gotop
/etc/xdg/gotop

The log file is in /home/pi/.cache/gotop/errors.log
$ cat /home/pi/.cache/gotop/errors.log
(empty)

@Tigerfyj
Copy link
Author

Oh, the previous error messages is in the file: ~/.local/state/gotop/errors.log.

$ cat /home/pi/.local/state/gotop/errors.log
00:04:54 cpu.go:102: error: number of CPU usage percents from gopsutil doesn't match CPU count. percents: [7.000000000061846 6.999999999608917 1.0101010100866268 9.99999999994543]. self.Count: 0
00:04:55 cpu.go:102: error: number of CPU usage percents from gopsutil doesn't match CPU count. percents: [0 7.216494845585563 5.999999999994543 0]. self.Count: 0

@Tigerfyj
Copy link
Author

I also run "go get" to build a version on my raspberry pi. The result is same.

$ git rev-parse HEAD
e2879e9

@xxxserxxx
Copy link
Owner

xxxserxxx commented Jun 23, 2020

@Tigerfyj , can you try this binary please? It adds some logging to the proc widget -- it should dump a lot of stuff to the log; I only need a sample.

@Tigerfyj
Copy link
Author

Tigerfyj commented Jun 23, 2020 via email

@xxxserxxx
Copy link
Owner

@Tigerfyj I'm not familiar with Raspberry, or the ARM options. I thought armv71 was arm64, but I see you said you use the arm6 executable -- I missed that. Try this binary.

gotop.zip

@Tigerfyj
Copy link
Author

Tigerfyj commented Jun 24, 2020 via email

@xxxserxxx
Copy link
Owner

@Tigerfyj , I don't see an attachment -- did github add it correctly?

@Tigerfyj
Copy link
Author

Tigerfyj commented Jun 25, 2020 via email

@Tigerfyj
Copy link
Author

Oh, I didn't realize that is auto-generated email. Upload the log file here.
errors.log.zip

@Tigerfyj
Copy link
Author

I tried to add some logs today. I can confirm the reason is the cpuCount is zero at line 52 of proc.go without an error. code link.
It returns the correct number if I change the parameter from false to true. It's wierd because the CPU widget always works correctly.

@xxxserxxx
Copy link
Owner

xxxserxxx commented Jun 25, 2020

It looks like there are some issues with gopsutil's support of CPU counting. The code needs a check in any case, but to get a correct % calculation, we'll need that root cause bug to be addressed.

Does this issue look similar? In particular, what are the outputs of

    lscpu
    grep -n . /sys/devices/system/cpu/cpu[0-9]*/topology/core_id

I'd like to gather as much information as possible about this so I can add it to shirou/gopsutil#849.

Edit

@Tigerfyj, could you also run this bit of code, please? Just stick in the gotop clone you have and run go run ./test.go

package main
import "fmt"
import "github.com/shirou/gopsutil/cpu"
func main() {
    t, _ := cpu.Counts(true)
    f, _ := cpu.Counts(false)
    fmt.Printf("true: %d, false: %d\n", t, f)
}

I'm expecting to see some non-0 number for true, and 0 for false. Thanks. (Edit 2, fixed syntax)

@Tigerfyj
Copy link
Author

Here is the output.

$ lscpu
Architecture:        armv7l
Byte Order:          Little Endian
CPU(s):              4
On-line CPU(s) list: 0-3
Thread(s) per core:  1
Core(s) per socket:  4
Socket(s):           1
Vendor ID:           ARM
Model:               4
Model name:          Cortex-A53
Stepping:            r0p4
CPU max MHz:         1400.0000
CPU min MHz:         600.0000
BogoMIPS:            38.40
Flags:               half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
$ grep -n . /sys/devices/system/cpu/cpu[0-9]*/topology/core_id
/sys/devices/system/cpu/cpu0/topology/core_id:1:0
/sys/devices/system/cpu/cpu1/topology/core_id:1:1
/sys/devices/system/cpu/cpu2/topology/core_id:1:2
/sys/devices/system/cpu/cpu3/topology/core_id:1:3
$ go run test.go
true: 4, false: 0

@xxxserxxx
Copy link
Owner

@Tigerfyj are you able to build from branch v4.0.2 and test the changes I just committed?

I think the percentages are not entirely accurate, but this isn't specific to ARM and there's another ticket about it. However, try this and see if you at least get some numbers. If so, then we'll close this and when I find the issue leading to the CPU usage discrepancies I'll make sure it works for ARM as well.

@Tigerfyj
Copy link
Author

Thanks! The v4.0.2 shows the cpu usages!

@xxxserxxx xxxserxxx modified the milestones: v4.0.2, v4.1.0 Aug 25, 2020
@Lomanic
Copy link

Lomanic commented Sep 20, 2020

@xxxserxxx FYI this is fixed with gopsutil current master (shirou/gopsutil#944), the fix is to be included in the next release at the end of the month. I could confirm it against an armv7 host. One can ensure this by running the cpu tests with go test github.com/shirou/gopsutil/cpu (the tests now both test logical and physical counts and compare the results against lscpu) after pulling gopsutil master.

@normen
Copy link

normen commented Dec 8, 2020

Is this fix only available through the v4.0.2 branch currently?

@xxxserxxx
Copy link
Owner

Hm. I merged it into master a while back, but it hasn't yet been released. Between a move and the holidays, I haven't had time to clean up and do a new release. Maybe before 2021? Maybe?

@normen
Copy link

normen commented Dec 10, 2020 via email

@xxxserxxx
Copy link
Owner

@Tigerfyj , @normen would you mind checking the version I released yesterday (v4.1.0) and see if this is still a problem?

@normen
Copy link

normen commented Jan 27, 2021

@Tigerfyj , @normen would you mind checking the version I released yesterday (v4.1.0) and see if this is still a problem?

Hey. Yes, the latest master displays the CPU load properly on my Pi3. Thanks!

@Tigerfyj
Copy link
Author

Works on my Pi4 as well! Thanks for your effort!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs:question Further information is requested os:linux
Projects
None yet
Development

No branches or pull requests

4 participants