forked from JointCloud/pcm-coordinator
Merge pull request 'bug fix' (#337) from zhangweiii/pcm-coordinator:master into master
This commit is contained in:
commit
98d071f750
|
@ -26,8 +26,8 @@ func NewCenterResourcesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *C
|
|||
}
|
||||
}
|
||||
|
||||
func (l *CenterResourcesLogic) CenterResources() (resp *types.CenterResourcesResp, err error) {
|
||||
resp = &types.CenterResourcesResp{}
|
||||
func (l *CenterResourcesLogic) CenterResources() (*types.CenterResourcesResp, error) {
|
||||
resp := &types.CenterResourcesResp{}
|
||||
rawData, err := l.svcCtx.PromClient.GetRawData("center_top3", tracker.AdapterOption{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -45,9 +45,15 @@ func (l *CenterResourcesLogic) CenterResources() (resp *types.CenterResourcesRes
|
|||
}
|
||||
for _, centerIndex := range centersIndex {
|
||||
// Query the types of resource centers
|
||||
l.svcCtx.DbEngin.Raw("select name,type as CenterType from t_adapter where id = ?", centerIndex.Id).Scan(¢erIndex)
|
||||
tx := l.svcCtx.DbEngin.Raw("select name,type as CenterType from t_adapter where id = ?", centerIndex.Id).Scan(¢erIndex)
|
||||
if tx.Error != nil {
|
||||
return nil, tx.Error
|
||||
}
|
||||
var clustersName string
|
||||
l.svcCtx.DbEngin.Raw("SELECT GROUP_CONCAT(name SEPARATOR '|' ) as clustersName from t_cluster where adapter_id = ?", centerIndex.Id).Scan(&clustersName)
|
||||
tx = l.svcCtx.DbEngin.Raw("SELECT GROUP_CONCAT(name SEPARATOR '|' ) as clustersName from t_cluster where adapter_id = ?", centerIndex.Id).Scan(&clustersName)
|
||||
if tx.Error != nil {
|
||||
return nil, tx.Error
|
||||
}
|
||||
cpuRawData, err := l.svcCtx.PromClient.GetRawData("center_cpu_utilisation", tracker.AdapterOption{AdapterId: centerIndex.Id, ClustersName: clustersName})
|
||||
cpuData := cpuRawData.(model.Vector)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue