shirou / gopsutil

psutil for golang
Other
10.36k stars 1.57k forks source link

Mac OS Apple M1 get cpu info failed "no such file or directory" #1598

Closed Felixyang2088 closed 5 months ago

Felixyang2088 commented 5 months ago

Describe the bug Get cpu info failed , log info "no such file or directory"

To Reproduce

    cpuInfos, err := cpu.Info()
    if err != nil {
        logrus.Errorf("get cpu info failed : %v", err)
        //return
    }
    for _, ci := range cpuInfos {
        logrus.Infof("CPU: %+v", ci)
    }

Expected behavior [A clear and concise description of what you expected to happen.]

Environment (please complete the following information):

Additional context go env ░▒▓ ✔  base   12:12:25  GO111MODULE='' GOARCH='arm64' GOBIN='' GOCACHE='/Users/guangyang/Library/Caches/go-build' GOENV='/Users/guangyang/Library/Application Support/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='arm64' GOHOSTOS='darwin' GOINSECURE='' GOMODCACHE='/Users/guangyang/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='darwin' GOPATH='/Users/guangyang/go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/opt/homebrew/Cellar/go/1.21.0/libexec' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/opt/homebrew/Cellar/go/1.21.0/libexec/pkg/tool/darwin_arm64' GOVCS='' GOVERSION='go1.21.0' GCCGO='gccgo' AR='ar' CC='cc' CXX='c++' CGO_ENABLED='1' GOMOD='/dev/null' GOWORK='' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' PKG_CONFIG='pkg-config' GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/yb/vy0wdpkx0jx6fyb7rmh1y5ph0000gn/T/go-build1627533097=/tmp/go-build -gno-record-gcc-switches -fno-common'

shirou commented 5 months ago

You mean, cpu.Info() returns no such file or directory on the err return value? However, it seems cpu.info() does not read any files. Could you tell us which version of gopsutil you are using?

dvovk commented 5 months ago

Looks like I have the same issue "Error: no such file or directory" on version github.com/shirou/gopsutil v3.21.11+incompatible. This error returns for each call to unix.Sysctl in func InfoWithContext(ctx context.Context) ([]InfoStat, error) I am testing on "M3 Max"

On github.com/shirou/gopsutil/v3 v3.24.1 this is info which I got CPU:0 VendorID:"" Family:"0" Model:"0" Stepping:0 PhysicalID:"" CoreID:"" Cores:16 ModelName:"Apple M3 Max" Mhz:4056 CacheSize:0 Flags:[]string len: 0, cap: 0, nil Microcode:""

Lomanic commented 5 months ago

Duplicate of #1000, update to /v3 (github.com/shirou/gopsutil/v3/cpu).