CPU usage not shown on Raspberry Pi
-
I have experienced exactly the same problem on a Raspberry Pi Zero W as the one desribed in https://ww.wp.xz.cn/support/topic/cpu-usages-unknow/ (marked as resolved, though it hasn’t been), i.e. CPU and core count looks like this:
Total CPUs : 0 / Coresin the dashboard, an no proper cpu usage is displayed.
I have looked at what the shell command on
produces when executed on the command line. On my desktp machine (WSL on Windows 10, Ubuntu 20.04) that looks like
$ cmd="echo \"$((<code>cat /proc/cpuinfo | grep cores | grep -o '[0-9]' | uniq<code>*</code>cat /proc/cpuinfo |grep 'physical id' | sort | uniq | wc -l))\""
$ $cmd
"4"But on the Raspberry Pi, the same line throws the error
$ cmd="echo \"$((<code>cat /proc/cpuinfo | grep cores | grep -o '[0-9]' | uniq<code>*</code>cat /proc/cpuinfo |grep 'physical id' | sort | uniq | wc -l))\""
-bash: * 0: syntax error: operand expected (error token is "* 0")which is likely to the content
$ cat /proc/cpuinfo processor : 0 model name : ARMv6-compatible processor rev 7 (v6l) BogoMIPS : 997.08 Features : half thumb fastmult vfp edsp java tls CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xb76 CPU revision : 7 Hardware : BCM2835 Revision : 9000c1 Serial : 0000000009f322bb Model : Raspberry Pi Zero W Rev 1.1not exhibiting any
cpu coresfield, differing from what the desktop machine would show for every processor.$ cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 142 model name : Intel(R) Core(TM) i5-10310U CPU @ 1.70GHz stepping : 12 microcode : 0xffffffff cpu MHz : 2208.004 cache size : 6144 KB physical id : 0 siblings : 8 core id : 0 cpu cores : 4 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 21 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves flush_l1d arch_capabilities bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs taa itlb_multihit srbds bogomips : 4416.00 clflush size : 64 cache_alignment : 64 address sizes : 39 bits physical, 48 bits virtual power management: ...Similarly, there is no field
physical idwithin the RPi’scpuinfo, hence the CPU count at https://github.com/isaumya/wp-server-stats/blob/37a0d1ccd9ed10915fc0bdb58672d32f9aeb1bce/wp-server-stats.php#L296 wont’t work neither.For similar reasons, determining the cpu load at https://github.com/isaumya/wp-server-stats/blob/37a0d1ccd9ed10915fc0bdb58672d32f9aeb1bce/wp-server-stats.php#L609 won’t work neither.
Summing up, if one would want to have the CPU count and load displayed proprly on a Rasberry Pi, the way to gou would be to clone the git repository and apply platform-specific modifications to the three lines of code linked above.
Best,
Johannes
The topic ‘CPU usage not shown on Raspberry Pi’ is closed to new replies.