diff --git a/api/desc/core/pcm-core.api b/api/desc/core/pcm-core.api index 128c9c5c..bd1905c9 100644 --- a/api/desc/core/pcm-core.api +++ b/api/desc/core/pcm-core.api @@ -18,9 +18,9 @@ type ( } ResourceUsage { - cpu int64 `json:"cpu"` - memory int64 `json:"memory"` - storage int64 `json:"storage"` + cpu float64 `json:"cpu"` + memory float64 `json:"memory"` + storage float64 `json:"storage"` } ResourceTotal { diff --git a/api/internal/logic/core/resourcecenterinfologic.go b/api/internal/logic/core/resourcecenterinfologic.go index ff5682b1..e37b4b65 100644 --- a/api/internal/logic/core/resourcecenterinfologic.go +++ b/api/internal/logic/core/resourcecenterinfologic.go @@ -32,6 +32,6 @@ func (l *ResourceCenterInfoLogic) ResourceCenterInfo(req *types.ResourceCenterIn l.svcCtx.DbEngin.Raw("select SUm(cpu_total) as cpu,sum(mem_total) as memory,SUM(disk_total) as storage FROM sc_node_avail_info where participant_id = ? GROUP BY created_time ORDER BY created_time desc LIMIT 1", req.ParticipantId).Scan(&resp.ResourceTotal) - l.svcCtx.DbEngin.Raw("select IFNULL(SUM(cpu_usable)/COUNT(*),0)as cpu,IFNULL(sum(mem_avail)/SUM(mem_total),0) as memory,IFNULL(sum(disk_avail)/SUM(disk_total),0) as storage FROM sc_node_avail_info where participant_id = ? GROUP BY created_time ORDER BY created_time desc LIMIT 1", req.ParticipantId).Scan(&resp.ResourceUsage) + l.svcCtx.DbEngin.Raw("select IFNULL(SUM(cpu_usable)/COUNT(*),0)as cpu,IFNULL(sum(mem_avail)/SUM(mem_total),0) as memory,IFNULL(sum(disk_avail)/SUM(disk_total),0) as storage FROM sc_node_avail_info where cpu_total != 0 and participant_id = ? GROUP BY created_time ORDER BY created_time desc LIMIT 1", req.ParticipantId).Scan(&resp.ResourceUsage) return } diff --git a/api/internal/types/types.go b/api/internal/types/types.go index d6e4382a..2e52c925 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -13,9 +13,9 @@ type ResourceCenterInfoResp struct { } type ResourceUsage struct { - Cpu int64 `json:"cpu"` - Memory int64 `json:"memory"` - Storage int64 `json:"storage"` + Cpu float64 `json:"cpu"` + Memory float64 `json:"memory"` + Storage float64 `json:"storage"` } type ResourceTotal struct {