-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpu_linux.go
46 lines (40 loc) · 1.22 KB
/
cpu_linux.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// MinIO Inc [madmin-go]
// Copyright (c) 2014-2025 MinIO.
// All rights reserved. No warranty, explicit or implicit, provided.
//
//go:build linux
// +build linux
package madmin
import (
"github.com/prometheus/procfs/sysfs"
)
func getCPUFreqStats() ([]CPUFreqStats, error) {
fs, err := sysfs.NewFS("/sys")
if err != nil {
return nil, err
}
stats, err := fs.SystemCpufreq()
if err != nil {
return nil, err
}
out := make([]CPUFreqStats, 0, len(stats))
for _, stat := range stats {
out = append(out, CPUFreqStats{
Name: stat.Name,
CpuinfoCurrentFrequency: stat.CpuinfoCurrentFrequency,
CpuinfoMinimumFrequency: stat.CpuinfoMinimumFrequency,
CpuinfoMaximumFrequency: stat.CpuinfoMaximumFrequency,
CpuinfoTransitionLatency: stat.CpuinfoTransitionLatency,
ScalingCurrentFrequency: stat.ScalingCurrentFrequency,
ScalingMinimumFrequency: stat.ScalingMinimumFrequency,
ScalingMaximumFrequency: stat.ScalingMaximumFrequency,
AvailableGovernors: stat.AvailableGovernors,
Driver: stat.Driver,
Governor: stat.Governor,
RelatedCpus: stat.RelatedCpus,
SetSpeed: stat.SetSpeed,
})
}
return out, nil
}