Fix staticcheck ST1003 warnings (#1249)
This fixes a few staticcheck ST1003 warnings in OpenBSD CPU collector. No functional change. Signed-off-by: Ralf Horstmann <ralf+github@ackstorm.de>
This commit is contained in:
parent
62e87ca00c
commit
dda51ad06a
|
@ -34,10 +34,10 @@ type cpuCollector struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registerCollector("cpu", defaultEnabled, NewCpuCollector)
|
registerCollector("cpu", defaultEnabled, NewCPUCollector)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCpuCollector() (Collector, error) {
|
func NewCPUCollector() (Collector, error) {
|
||||||
return &cpuCollector{
|
return &cpuCollector{
|
||||||
cpu: typedDesc{nodeCPUSecondsDesc, prometheus.CounterValue},
|
cpu: typedDesc{nodeCPUSecondsDesc, prometheus.CounterValue},
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -56,18 +56,18 @@ func (c *cpuCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var cp_time [][C.CPUSTATES]C.int64_t
|
var cpTime [][C.CPUSTATES]C.int64_t
|
||||||
for i := 0; i < int(ncpus); i++ {
|
for i := 0; i < int(ncpus); i++ {
|
||||||
cp_timeb, err := unix.SysctlRaw("kern.cp_time2", i)
|
cpb, err := unix.SysctlRaw("kern.cp_time2", i)
|
||||||
if err != nil && err != unix.ENODEV {
|
if err != nil && err != unix.ENODEV {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err != unix.ENODEV {
|
if err != unix.ENODEV {
|
||||||
cp_time = append(cp_time, *(*[C.CPUSTATES]C.int64_t)(unsafe.Pointer(&cp_timeb[0])))
|
cpTime = append(cpTime, *(*[C.CPUSTATES]C.int64_t)(unsafe.Pointer(&cpb[0])))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for cpu, time := range cp_time {
|
for cpu, time := range cpTime {
|
||||||
lcpu := strconv.Itoa(cpu)
|
lcpu := strconv.Itoa(cpu)
|
||||||
ch <- c.cpu.mustNewConstMetric(float64(time[C.CP_USER])/hz, lcpu, "user")
|
ch <- c.cpu.mustNewConstMetric(float64(time[C.CP_USER])/hz, lcpu, "user")
|
||||||
ch <- c.cpu.mustNewConstMetric(float64(time[C.CP_NICE])/hz, lcpu, "nice")
|
ch <- c.cpu.mustNewConstMetric(float64(time[C.CP_NICE])/hz, lcpu, "nice")
|
||||||
|
|
Loading…
Reference in New Issue