Koordinator-NodeInfoCollector
Run
每秒执行一次
func (n *nodeInfoCollector) Run(stopCh <-chan struct{}) {go wait.Until(n.collectNodeInfo, n.collectInterval, stopCh)
}
collectNodeInfo()
- 采集node cpu信息
- 采集node numa信息
func (n *nodeInfoCollector) collectNodeInfo() {started := time.Now()err := n.collectNodeCPUInfo()if err != nil {klog.Warningf("failed to collect node CPU info, err: %s", err)return}err = n.collectNodeNUMAInfo()if err != nil {klog.Warningf("failed to collect node NUMA info, err: %s", err)return}n.started.Store(true)klog.V(4).Infof("collect node info finished, elapsed %s", time.Since(started).String())
}
collectNodeCPUInfo()
- 采集和组装NodeCpuInfo对象
- 缓存到key为node_cpu_info
- 记录到metric,
collect_node_cpu_info_status:status=successed
func (n *nodeInfoCollector) collectNodeCPUInfo() error {klog.V(6).Info("start collect node cpu info")localCPUInfo, err := koordletutil.GetLocalCPUInfo()if err != nil {metrics.RecordCollectNodeCPUInfoStatus(err)return err}nodeCPUInfo := &metriccache.NodeCPUInfo{BasicInfo: localCPUInfo.BasicInfo,ProcessorInfos: localCPUInfo.ProcessorInfos,TotalInfo: localCPUInfo.TotalInfo,}klog.V(6).Infof("collect cpu info finished, info: %+v", nodeCPUInfo)n.storage.Set(metriccache.NodeCPUInfoKey, nodeCPUInfo)klog.V(4).Infof("collectNodeCPUInfo finished, processors num %v", len(nodeCPUInfo.ProcessorInfos))metrics.RecordCollectNodeCPUInfoStatus(nil)return nil
}
GetLocalCPUInfo()
命令lscpu -e=CPU,NODE,SOCKET,CORE,CACHE,ONLINE
CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE
0 0 0 0 0:0:0:0 是
1 0 0 0 0:0:0:0 是
组装信息:
LocalCPUInfo{"basicInfo":{"hyperThreadEnabled":true,"catL3CbmMask":"","vendorID":"GenuineIntel",},"processorInfos":[{"cpu":0,"core":0, "socket":0, "node":0, "l1dl1il2":"0:0:0", "l3":0, "online":"是"},{"cpu":1,"core":0, "socket":0, "node":0, &#