Skip to content

Commit

Permalink
fix host cpu lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
cha87de committed Dec 29, 2018
1 parent e8752a1 commit f53eca0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion util/sys-cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type SysCPU struct {
func GetSysCPU() []SysCPU {
stats := []SysCPU{}

files, err := filepath.Glob("/sys/devices/system/cpu/cpu[0-999]")
files, err := filepath.Glob("/sys/devices/system/cpu/cpu[0-9]*")
if err != nil {
fmt.Fprintf(os.Stderr, "Cannot read cpu infos from sys fs: %s\n", err)
return stats
Expand Down

3 comments on commit f53eca0

@MyungChi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no /cpufreq directory under above directory. According to source code you are trying to get cpuinfo_[max|min|cur]_freq. But In my system, There are no "/cpufreq" directory under "/sys/devices/system/cpu/cpu*" as below. It might has occurred error on for loop.

pwd

/sys/devices/system/cpu/cpu0

ls -al

total 0
drwxr-xr-x. 8 root root 0 Feb 27 00:06 .
drwxr-xr-x. 95 root root 0 Feb 27 00:07 ..
drwxr-xr-x. 6 root root 0 Apr 16 14:29 cache
drwxr-xr-x. 6 root root 0 Apr 16 14:29 cpuidle
-r--------. 1 root root 4096 Apr 16 14:29 crash_notes
-r--------. 1 root root 4096 Apr 16 14:29 crash_notes_size
lrwxrwxrwx. 1 root root 0 Apr 16 14:29 driver -> ../../../../bus/cpu/drivers/processor
lrwxrwxrwx. 1 root root 0 Apr 16 14:29 firmware_node -> ../../../LNXSYSTM:00/device:00/ACPI0004:00/LNXCPU:00
drwxr-xr-x. 2 root root 0 Apr 16 14:29 microcode
lrwxrwxrwx. 1 root root 0 Apr 16 14:29 node0 -> ../../node/node0
-rw-r--r--. 1 root root 4096 Apr 16 14:29 online
drwxr-xr-x. 2 root root 0 Apr 16 14:29 power
lrwxrwxrwx. 1 root root 0 Apr 16 14:29 subsystem -> ../../../../bus/cpu
drwxr-xr-x. 2 root root 0 Apr 16 14:29 thermal_throttle
drwxr-xr-x. 2 root root 0 Jan 8 14:15 topology
-rw-r--r--. 1 root root 4096 Apr 16 14:29 uevent

@cha87de
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What operating system, what kernel do you use?

@MyungChi
Copy link

@MyungChi MyungChi commented on f53eca0 Apr 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my system info.

cat /etc/redhat-release

CentOS Linux release 7.5.1804 (Core)

uname -r

3.10.0-862.14.4.el7.x86_64

Please sign in to comment.