| @@ -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{}) | rawData, err := l.svcCtx.PromClient.GetRawData("center_top3", tracker.AdapterOption{}) | ||||
| if err != nil { | if err != nil { | ||||
| return nil, err | return nil, err | ||||
| @@ -45,9 +45,15 @@ func (l *CenterResourcesLogic) CenterResources() (resp *types.CenterResourcesRes | |||||
| } | } | ||||
| for _, centerIndex := range centersIndex { | for _, centerIndex := range centersIndex { | ||||
| // Query the types of resource centers | // 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 | 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}) | cpuRawData, err := l.svcCtx.PromClient.GetRawData("center_cpu_utilisation", tracker.AdapterOption{AdapterId: centerIndex.Id, ClustersName: clustersName}) | ||||
| cpuData := cpuRawData.(model.Vector) | cpuData := cpuRawData.(model.Vector) | ||||
| if err != nil { | if err != nil { | ||||