mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-26 15:29:04 +01:00
Reuse information from /proc/cpuinfo
This commit is contained in:
parent
ae106566dd
commit
1f5856c671
@ -92,16 +92,6 @@ func init() {
|
||||
slices.Sort(cache.uniqSocketList)
|
||||
cache.uniqSocketList = slices.Compact(cache.uniqSocketList)
|
||||
|
||||
getCore :=
|
||||
func(basePath string) int {
|
||||
return fileToInt(filepath.Join(basePath, "core_id"))
|
||||
}
|
||||
|
||||
getSocket :=
|
||||
func(basePath string) int {
|
||||
return fileToInt(filepath.Join(basePath, "physical_package_id"))
|
||||
}
|
||||
|
||||
getDie :=
|
||||
func(basePath string) int {
|
||||
return fileToInt(filepath.Join(basePath, "die_id"))
|
||||
@ -149,18 +139,16 @@ func init() {
|
||||
return 0
|
||||
}
|
||||
|
||||
for _, c := range cache.HwthreadList {
|
||||
cache.CpuData =
|
||||
append(
|
||||
cache.CpuData,
|
||||
HwthreadEntry{
|
||||
CpuID: c,
|
||||
Socket: -1,
|
||||
NumaDomain: -1,
|
||||
Die: -1,
|
||||
Core: -1,
|
||||
},
|
||||
)
|
||||
cache.CpuData = make([]HwthreadEntry, len(cache.HwthreadList))
|
||||
for i := range cache.HwthreadList {
|
||||
cache.CpuData[i] =
|
||||
HwthreadEntry{
|
||||
CpuID: cache.HwthreadList[i],
|
||||
Socket: cache.SocketList[i],
|
||||
NumaDomain: -1,
|
||||
Die: -1,
|
||||
Core: cache.CoreList[i],
|
||||
}
|
||||
}
|
||||
for i := range cache.CpuData {
|
||||
cEntry := &cache.CpuData[i]
|
||||
@ -170,12 +158,6 @@ func init() {
|
||||
base := filepath.Join("/sys/devices/system/cpu", cpuStr)
|
||||
topoBase := filepath.Join(base, "topology")
|
||||
|
||||
// Lookup CPU core id
|
||||
cEntry.Core = getCore(topoBase)
|
||||
|
||||
// Lookup CPU socket id
|
||||
cEntry.Socket = getSocket(topoBase)
|
||||
|
||||
// Lookup CPU die id
|
||||
cEntry.Die = getDie(topoBase)
|
||||
if cEntry.Die < 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user