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

BUG: cpu.Info() doesn't work on OpenBSD (7.5) #1710

Open
1 of 5 tasks
iredmail opened this issue Sep 13, 2024 · 5 comments
Open
1 of 5 tasks

BUG: cpu.Info() doesn't work on OpenBSD (7.5) #1710

iredmail opened this issue Sep 13, 2024 · 5 comments

Comments

@iredmail
Copy link

Describe the bug

cpu.Info() doesn't work on OpenBSD, version 7.5, MacBook Pro with M3 Pro chip (arm64).

To Reproduce

import "github.com/shirou/gopsutil/v4/cpu"

_, err := cpu.Info()

It reports error operation not supported.

Expected behavior

Expect it collects at least number of CPU cores.

Environment (please complete the following information):

  • Windows: [paste the result of ver]
  • Linux: [paste contents of /etc/os-release and the result of uname -a]
  • Mac OS: [paste the result of sw_vers and uname -a
  • FreeBSD: [paste the result of freebsd-version -k -r -u and uname -a]
  • OpenBSD: [paste the result of uname -a]
# uname -a
OpenBSD ob75.localdomain 7.5 GENERIC#131 arm64
@landryb
Copy link

landryb commented Sep 13, 2024

afaik, direct syscalls as done in https://github.com/shirou/gopsutil/blob/master/cpu/cpu_openbsd.go#L59 are forbidden

@Lomanic
Copy link
Collaborator

Lomanic commented Sep 15, 2024

Sorry I don't reproduce on an openbsd 7.5 VM under VirtualBox

package main

import (
        "log"

        "github.com/shirou/gopsutil/v4/cpu"
)

func main() {
        log.Println("cpu.Info()")
        log.Println(cpu.Info())
}
openbsd75$ go run cpu.go
2024/09/15 16:59:55 cpu.Info()
2024/09/15 16:59:55 [{"cpu":0,"vendorId":"","family":"","model":"","stepping":0,"physicalId":"","coreId":"","cores":1,"modelName":"Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz","mhz":2506,"cacheSize":0,"flags":null,"microcode":""}] <nil>

Are you restricting your Go program with something like plegde/unveil maybe?

@iredmail
Copy link
Author

iredmail commented Sep 16, 2024

FYI golang/go#63900
Same code doesn't work for me with Go 1.22.1 (the binary package installed via pkg_add go), OpenBSD 7.5 is running in VMware Fusion, hardware is MacBook Pro (M3 Pro CPU).

# uname -a     
OpenBSD ob75.localdomain 7.5 GENERIC#131 arm64

# cat main.go  
package main

import (
        "log"

        "github.com/shirou/gopsutil/v4/cpu"
)

func main() {
        log.Println("cpu.Info()")
        log.Println(cpu.Info())
}

# go run .     
2024/09/16 01:13:54 cpu.Info()
2024/09/16 01:13:54 [] operation not supported

@Lomanic
Copy link
Collaborator

Lomanic commented Oct 18, 2024

I was also testing with go version go1.22.1 openbsd/amd64, the difference is arm64 vs amd64.

What's the result of this shell oneliner (sysctl values from here)?

for I in hw.cpuspeed hw.ncpuonline hw.model; do printf "%s: " "$I"; sysctl "$I"; done

@iredmail
Copy link
Author

iredmail commented Oct 19, 2024

@Lomanic

Running on OpenBSD 7.6 (arm64), which is a VM guest inside VMware Fusion (MacBook Pro with Apple M3 Pro chip):

# for I in hw.cpuspeed hw.ncpuonline hw.model; do printf "%s: " "$I"; sysctl "$I"; done
hw.cpuspeed: sysctl: hw.cpuspeed: value is not available
hw.ncpuonline: hw.ncpuonline=1
hw.model: hw.model=Unknown

# uname -r -m 
7.6 arm64

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

3 participants