collector/cpu: s/cpu_ticks*/cpu_nsec* for solaris (#2963)

Replace all cpu_ticks_* with cpu_nsec_*, since the former was off my a
magnitude of 10e6, and showed incorrect values for
node_cpu_seconds_total.

Fixes: #1837

Signed-off-by: Pranshu Srivastava <rexagod@gmail.com>
This commit is contained in:
Pranshu Srivastava 2024-05-15 12:43:32 +05:30 committed by GitHub
parent 2ecbe97066
commit 66fab10db4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -60,17 +60,17 @@ func (c *cpuCollector) Update(ch chan<- prometheus.Metric) error {
} }
for k, v := range map[string]string{ for k, v := range map[string]string{
"idle": "cpu_ticks_idle", "idle": "cpu_nsec_idle",
"kernel": "cpu_ticks_kernel", "kernel": "cpu_nsec_kernel",
"user": "cpu_ticks_user", "user": "cpu_nsec_user",
"wait": "cpu_ticks_wait", "wait": "cpu_nsec_wait",
} { } {
kstatValue, err := ksCPU.GetNamed(v) kstatValue, err := ksCPU.GetNamed(v)
if err != nil { if err != nil {
return err return err
} }
ch <- c.cpu.mustNewConstMetric(float64(kstatValue.UintVal), strconv.Itoa(cpu), k) ch <- c.cpu.mustNewConstMetric(float64(kstatValue.UintVal)/1e9, strconv.Itoa(cpu), k)
} }
} }
return nil return nil