mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-27 23:59:05 +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)
|
slices.Sort(cache.uniqSocketList)
|
||||||
cache.uniqSocketList = slices.Compact(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 :=
|
getDie :=
|
||||||
func(basePath string) int {
|
func(basePath string) int {
|
||||||
return fileToInt(filepath.Join(basePath, "die_id"))
|
return fileToInt(filepath.Join(basePath, "die_id"))
|
||||||
@ -149,18 +139,16 @@ func init() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, c := range cache.HwthreadList {
|
cache.CpuData = make([]HwthreadEntry, len(cache.HwthreadList))
|
||||||
cache.CpuData =
|
for i := range cache.HwthreadList {
|
||||||
append(
|
cache.CpuData[i] =
|
||||||
cache.CpuData,
|
|
||||||
HwthreadEntry{
|
HwthreadEntry{
|
||||||
CpuID: c,
|
CpuID: cache.HwthreadList[i],
|
||||||
Socket: -1,
|
Socket: cache.SocketList[i],
|
||||||
NumaDomain: -1,
|
NumaDomain: -1,
|
||||||
Die: -1,
|
Die: -1,
|
||||||
Core: -1,
|
Core: cache.CoreList[i],
|
||||||
},
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
for i := range cache.CpuData {
|
for i := range cache.CpuData {
|
||||||
cEntry := &cache.CpuData[i]
|
cEntry := &cache.CpuData[i]
|
||||||
@ -170,12 +158,6 @@ func init() {
|
|||||||
base := filepath.Join("/sys/devices/system/cpu", cpuStr)
|
base := filepath.Join("/sys/devices/system/cpu", cpuStr)
|
||||||
topoBase := filepath.Join(base, "topology")
|
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
|
// Lookup CPU die id
|
||||||
cEntry.Die = getDie(topoBase)
|
cEntry.Die = getDie(topoBase)
|
||||||
if cEntry.Die < 0 {
|
if cEntry.Die < 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user