Merge pull request #624 from ajacoutot/cpu-openbsd

cpu: implement Mhz and Cores on OpenBSD
pull/629/head
shirou 6 years ago committed by GitHub
commit d94da856e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -124,14 +124,24 @@ func Info() ([]InfoStat, error) {
func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
var ret []InfoStat
var err error
c := InfoStat{}
v, err := unix.Sysctl("hw.model")
if err != nil {
var u32 uint32
if u32, err = unix.SysctlUint32("hw.cpuspeed"); err != nil {
return nil, err
}
c.Mhz = float64(u32)
if u32, err = unix.SysctlUint32("hw.ncpuonline"); err != nil {
return nil, err
}
c.Cores = int32(u32)
if c.ModelName, err = unix.Sysctl("hw.model"); err != nil {
return nil, err
}
c.ModelName = v
return append(ret, c), nil
}

Loading…
Cancel
Save