Do not hand define struct clockinfo here. Instead use the version from (#2663)

x/sys/unix. The clockinfo struct was altered beginning of 2021 and this
code was not adjusted.

Signed-off-by: Claudio Jeker <claudio@openbsd.org>
This commit is contained in:
Claudio Jeker 2023-05-11 10:39:51 +02:00 committed by GitHub
parent 29c97c2197
commit 6251cc7b6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,14 +25,6 @@ import (
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
type clockinfo struct {
hz int32
tick int32
tickadj int32
stathz int32
profhz int32
}
const ( const (
CP_USER = iota CP_USER = iota
CP_NICE CP_NICE
@ -72,8 +64,8 @@ func (c *cpuCollector) Update(ch chan<- prometheus.Metric) (err error) {
if err != nil { if err != nil {
return err return err
} }
clock := *(*clockinfo)(unsafe.Pointer(&clockb[0])) clock := *(*unix.Clockinfo)(unsafe.Pointer(&clockb[0]))
hz := float64(clock.stathz) hz := float64(clock.Stathz)
ncpus, err := unix.SysctlUint32("hw.ncpu") ncpus, err := unix.SysctlUint32("hw.ncpu")
if err != nil { if err != nil {