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 · 3 comments
Open
1 of 5 tasks

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

iredmail opened this issue Sep 13, 2024 · 3 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

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