diff --git a/api/desc/core/pcm-core.api b/api/desc/core/pcm-core.api index e9bedc1c..e907723a 100644 --- a/api/desc/core/pcm-core.api +++ b/api/desc/core/pcm-core.api @@ -505,6 +505,36 @@ type ( } ) + +type ScreenChartResp { + ComputingPower []int `json:"computingPower"` + CpuAvg []int `json:"cpuAvg"` + CpuLoad []int `json:"cpuLoad"` + MemoryLoad []int `json:"memoryLoad"` + MemoryAvg []int `json:"memoryAvg"` + CenterName string `json:"centerName"` +} + + + +type ScreenInfoResp { + StorageUsed float32 `json:"storageUsed"` + StorageUsing float32 `json:"storageUsing"` + UsageRate float32 `json:"usageRate"` + UsingRate float32 `json:"usingRate"` + ApiDelay string `json:"apiDelay"` + SchedulerTimes int `json:"schedulerTimes"` + SchedulerErr int `json:"schedulerErr"` + ApiTimes string `json:"apiTimes"` + CenterCount int `json:"centerCount"` + ComputingPower float64 `json:"computingPower"` + ClusterCount int `json:"clusterCount"` + RunningCount int `json:"runningCount"` + CardCount int `json:"cardCount"` + RunningTime int `json:"runningTime"` +} + + type ( cpResp { POpsAtFp16 float32 `json:"pOpsAtFp16"` diff --git a/api/desc/pcm.api b/api/desc/pcm.api index 8ee57626..031ee517 100644 --- a/api/desc/pcm.api +++ b/api/desc/pcm.api @@ -154,6 +154,19 @@ service pcm { @doc "Get Public Network" @handler getPublicNetworkHandler get /core/getPublicNetwork (PublicNetworkReq) returns (PublicNetworkResp) + + @doc "screen" + @handler getDomainResourceHandler + get /core/getDomainResource returns (DomainResourceResp) + + @doc "screen" + @handler getScreenInfoHandler + get /core/getScreenInfo returns (ScreenInfoResp) + + @doc "screen" + @handler getScreenChartHandler + get /core/getScreenChart returns (ScreenChartResp) + } //hpc二级接口 @@ -386,11 +399,11 @@ service pcm { @doc "日常算力查询" @handler dailyPowerScreenHandler - get /storage/dailyPowerScreen (DailyPowerScreenReq) returns (DailyPowerScreenResp) + get /storage/dailyPowerScreen returns (DailyPowerScreenResp) @doc "算力中心算力情况" @handler perCenterComputerPowersHandler - get /storage/perCenterComputerPowers (PerCenterComputerPowersReq) returns (PerCenterComputerPowersResp) + get /storage/perCenterComputerPowers returns (PerCenterComputerPowersResp) } //openstack 接口 diff --git a/api/desc/storage/pcm-storage.api b/api/desc/storage/pcm-storage.api index 88086e79..2aaf5dbc 100644 --- a/api/desc/storage/pcm-storage.api +++ b/api/desc/storage/pcm-storage.api @@ -52,46 +52,14 @@ type ( /******************screen computing power Start*************************/ type ( - DailyPowerScreenReq { - - } - DailyPowerScreenResp { - TotalSize int32 `json:"totalSize" copier:"TotalSize"` - DailyComputerPowers []DailyComputerPowers `json:"dailyComputerPowers" copier:"DailyComputerPowers"` - Code int32 `json:"code,omitempty"` - Msg string `json:"msg,omitempty"` - ErrorMsg string `json:"ErrorMsg,omitempty"` - } - - DailyComputerPowers { - Date string `json:"date" copier:"Date"` - ComputerPower float32 `json:"computerPower" copier:"ComputerPower"` + // DailyComputerPowers []DailyComputerPowers `json:"dailyComputerPowers" copier:"DailyComputerPowers"` + chart interface{} `json:"chart"` } ) type ( - PerCenterComputerPowersReq { - - } PerCenterComputerPowersResp { - TotalSize int32 `json:"totalSize" copier:"TotalSize"` - PerCenterComputerPowers []PerCenterComputerPowers `json:"perCenterComputerPowers" copier:"PerCenterComputerPowers"` - AccOtJobInfo AccOtJobInfo `json:"accOtJobInfo" copier:"AccOtJobInfo"` - Code int32 `json:"code,omitempty"` - Msg string `json:"msg,omitempty"` - ErrorMsg string `json:"ErrorMsg,omitempty"` - } - - PerCenterComputerPowers { - CenterName string `json:"centerName" copier:"CenterName"` - ComputerPower float32 `json:"computerPower" copier:"ComputerPower"` - JobCount int32 `json:"jobCount" copier:"JobCount"` - CenterId string `json:"centerId" copier:"CenterId"` - } - AccOtJobInfo { - AccRunSec int32 `json:"accRunSec" copier:"AccRunSec"` - AccCardRunSec float32 `json:"accCardRunSec" copier:"AccCardRunSec"` - AccOtJobNum int32 `json:"accOtJobNum" copier:"AccOtJobNum"` + chart interface{} `json:"chart"` } ) diff --git a/api/internal/handler/core/getdomainresourcehandler.go b/api/internal/handler/core/getdomainresourcehandler.go new file mode 100644 index 00000000..6ab31112 --- /dev/null +++ b/api/internal/handler/core/getdomainresourcehandler.go @@ -0,0 +1,17 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" +) + +func GetDomainResourceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewGetDomainResourceLogic(r.Context(), svcCtx) + resp, err := l.GetDomainResource() + result.HttpResult(r, w, resp, err) + } +} diff --git a/api/internal/handler/core/getscreencharthandler.go b/api/internal/handler/core/getscreencharthandler.go new file mode 100644 index 00000000..64f7ea93 --- /dev/null +++ b/api/internal/handler/core/getscreencharthandler.go @@ -0,0 +1,17 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" +) + +func GetScreenChartHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewGetScreenChartLogic(r.Context(), svcCtx) + resp, err := l.GetScreenChart() + result.HttpResult(r, w, resp, err) + } +} diff --git a/api/internal/handler/core/getscreeninfohandler.go b/api/internal/handler/core/getscreeninfohandler.go new file mode 100644 index 00000000..65a28a6e --- /dev/null +++ b/api/internal/handler/core/getscreeninfohandler.go @@ -0,0 +1,17 @@ +package core + +import ( + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" + "net/http" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/core" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" +) + +func GetScreenInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + l := core.NewGetScreenInfoLogic(r.Context(), svcCtx) + resp, err := l.GetScreenInfo() + result.HttpResult(r, w, resp, err) + } +} diff --git a/api/internal/handler/routes.go b/api/internal/handler/routes.go index 00a8e345..c3315879 100644 --- a/api/internal/handler/routes.go +++ b/api/internal/handler/routes.go @@ -184,6 +184,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/core/getPublicNetwork", Handler: core.GetPublicNetworkHandler(serverCtx), }, + { + Method: http.MethodGet, + Path: "/core/getDomainResource", + Handler: core.GetDomainResourceHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/getScreenInfo", + Handler: core.GetScreenInfoHandler(serverCtx), + }, + { + Method: http.MethodGet, + Path: "/core/getScreenChart", + Handler: core.GetScreenChartHandler(serverCtx), + }, }, rest.WithPrefix("/pcm/v1"), ) diff --git a/api/internal/handler/storage/dailypowerscreenhandler.go b/api/internal/handler/storage/dailypowerscreenhandler.go index 878a536c..a71c2331 100644 --- a/api/internal/handler/storage/dailypowerscreenhandler.go +++ b/api/internal/handler/storage/dailypowerscreenhandler.go @@ -1,24 +1,17 @@ package storage import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storage" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" "net/http" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storage" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" ) func DailyPowerScreenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - var req types.DailyPowerScreenReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - l := storage.NewDailyPowerScreenLogic(r.Context(), svcCtx) - resp, err := l.DailyPowerScreen(&req) + resp, err := l.DailyPowerScreen() result.HttpResult(r, w, resp, err) } } diff --git a/api/internal/handler/storage/percentercomputerpowershandler.go b/api/internal/handler/storage/percentercomputerpowershandler.go index 15c7d3a1..b21a330b 100644 --- a/api/internal/handler/storage/percentercomputerpowershandler.go +++ b/api/internal/handler/storage/percentercomputerpowershandler.go @@ -1,24 +1,17 @@ package storage import ( - "github.com/zeromicro/go-zero/rest/httpx" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storage" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" - "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" "net/http" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/storage" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" ) func PerCenterComputerPowersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - var req types.PerCenterComputerPowersReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - l := storage.NewPerCenterComputerPowersLogic(r.Context(), svcCtx) - resp, err := l.PerCenterComputerPowers(&req) + resp, err := l.PerCenterComputerPowers() result.HttpResult(r, w, resp, err) } } diff --git a/api/internal/logic/adapters/createclusterlogic.go b/api/internal/logic/adapters/createclusterlogic.go index bb2e0eb1..f8d8a356 100644 --- a/api/internal/logic/adapters/createclusterlogic.go +++ b/api/internal/logic/adapters/createclusterlogic.go @@ -57,9 +57,10 @@ func (l *CreateClusterLogic) CreateCluster(req *types.ClusterCreateReq) (resp *t ForceContentType("application/json"). Post(adapterServer + "/api/v1/cluster/info") if err != nil { + return nil, err } if response.IsError() { - + return nil, errors.New(string(response.Body())) } return } diff --git a/api/internal/logic/core/getdomainresourcelogic.go b/api/internal/logic/core/getdomainresourcelogic.go new file mode 100644 index 00000000..f7f2acb0 --- /dev/null +++ b/api/internal/logic/core/getdomainresourcelogic.go @@ -0,0 +1,31 @@ +package core + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetDomainResourceLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetDomainResourceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDomainResourceLogic { + return &GetDomainResourceLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetDomainResourceLogic) GetDomainResource() (resp *types.DomainResourceResp, err error) { + resp = &types.DomainResourceResp{} + l.svcCtx.DbEngin.Raw("select * from screen_domain where delete_flag = 0").Scan(&resp.DomainResourceList) + return resp, nil + +} diff --git a/api/internal/logic/core/getscreenchartlogic.go b/api/internal/logic/core/getscreenchartlogic.go new file mode 100644 index 00000000..06085cf9 --- /dev/null +++ b/api/internal/logic/core/getscreenchartlogic.go @@ -0,0 +1,33 @@ +package core + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetScreenChartLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetScreenChartLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetScreenChartLogic { + return &GetScreenChartLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetScreenChartLogic) GetScreenChart() (resp *types.ScreenChartResp, err error) { + resp = &types.ScreenChartResp{} + l.svcCtx.DbEngin.Raw("select cpu_avg from screen_chart").Scan(&resp.CpuAvg) + l.svcCtx.DbEngin.Raw("select cpu_load from screen_chart").Scan(&resp.CpuLoad) + l.svcCtx.DbEngin.Raw("select memory_avg from screen_chart").Scan(&resp.MemoryAvg) + l.svcCtx.DbEngin.Raw("select memory_load from screen_chart").Scan(&resp.MemoryLoad) + return +} diff --git a/api/internal/logic/core/getscreeninfologic.go b/api/internal/logic/core/getscreeninfologic.go new file mode 100644 index 00000000..efeb6f5f --- /dev/null +++ b/api/internal/logic/core/getscreeninfologic.go @@ -0,0 +1,30 @@ +package core + +import ( + "context" + + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetScreenInfoLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetScreenInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetScreenInfoLogic { + return &GetScreenInfoLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetScreenInfoLogic) GetScreenInfo() (resp *types.ScreenInfoResp, err error) { + resp = &types.ScreenInfoResp{} + l.svcCtx.DbEngin.Raw("select * from screen").Scan(resp) + return +} diff --git a/api/internal/logic/storage/dailypowerscreenlogic.go b/api/internal/logic/storage/dailypowerscreenlogic.go index e07a8b3a..804b6b21 100644 --- a/api/internal/logic/storage/dailypowerscreenlogic.go +++ b/api/internal/logic/storage/dailypowerscreenlogic.go @@ -1,30 +1,13 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - package storage import ( "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils" + "k8s.io/apimachinery/pkg/util/json" + "strings" + "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/jcce-pcm/pcm-participant-ceph/ceph" - "k8s.io/apimachinery/pkg/util/json" "github.com/zeromicro/go-zero/core/logx" ) @@ -43,20 +26,15 @@ func NewDailyPowerScreenLogic(ctx context.Context, svcCtx *svc.ServiceContext) * } } -func (l *DailyPowerScreenLogic) DailyPowerScreen(req *types.DailyPowerScreenReq) (resp *types.DailyPowerScreenResp, err error) { - // todo: add your logic here and delete this line - dailyPowerScreenReq := &ceph.DailyPowerScreenReq{} - err = copier.CopyWithOption(dailyPowerScreenReq, req, copier.Option{Converters: utils.Converters}) - DailyPowerScreenResp, err := l.svcCtx.CephRpc.DailyPowerScreen(l.ctx, dailyPowerScreenReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db storage list"), "Failed to get db storage list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&DailyPowerScreenResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &DailyPowerScreenResp, copier.Option{Converters: utils.Converters}) +func (l *DailyPowerScreenLogic) DailyPowerScreen() (resp *types.DailyPowerScreenResp, err error) { + resp = &types.DailyPowerScreenResp{} + statusCode, body, err := httputils.HttpClientWithScreen(httputils.GET, "https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/dailytrend", strings.NewReader(``)) + if statusCode == 200 { + json.Unmarshal(body, &resp.Chart) + println(resp) + } else if statusCode != 200 { + return nil, err + } return resp, nil } diff --git a/api/internal/logic/storage/percentercomputerpowerslogic.go b/api/internal/logic/storage/percentercomputerpowerslogic.go index 669a3b6c..4813fbb1 100644 --- a/api/internal/logic/storage/percentercomputerpowerslogic.go +++ b/api/internal/logic/storage/percentercomputerpowerslogic.go @@ -1,30 +1,12 @@ -/* - - Copyright (c) [2023] [pcm] - [pcm-coordinator] is licensed under Mulan PSL v2. - You can use this software according to the terms and conditions of the Mulan PSL v2. - You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - See the Mulan PSL v2 for more details. - -*/ - package storage import ( "context" - "github.com/jinzhu/copier" - "github.com/pkg/errors" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/helper/xerr" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result" - "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils" - "gitlink.org.cn/jcce-pcm/pcm-participant-ceph/ceph" + "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils" "k8s.io/apimachinery/pkg/util/json" + "strings" "github.com/zeromicro/go-zero/core/logx" ) @@ -43,20 +25,15 @@ func NewPerCenterComputerPowersLogic(ctx context.Context, svcCtx *svc.ServiceCon } } -func (l *PerCenterComputerPowersLogic) PerCenterComputerPowers(req *types.PerCenterComputerPowersReq) (resp *types.PerCenterComputerPowersResp, err error) { - // todo: add your logic here and delete this line - perCenterComputerPowersReq := &ceph.PerCenterComputerPowersReq{} - err = copier.CopyWithOption(perCenterComputerPowersReq, req, copier.Option{Converters: utils.Converters}) - PerCenterComputerPowersResp, err := l.svcCtx.CephRpc.PerCenterComputerPowerScreen(l.ctx, perCenterComputerPowersReq) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrMsg("Failed to get db storage list"), "Failed to get db storage list err : %v ,req:%+v", err, req) - } - marshal, err := json.Marshal(&PerCenterComputerPowersResp) - if err != nil { - return nil, result.NewDefaultError(err.Error()) - } - json.Unmarshal(marshal, &resp) - err = copier.CopyWithOption(&resp, &PerCenterComputerPowersResp, copier.Option{Converters: utils.Converters}) +func (l *PerCenterComputerPowersLogic) PerCenterComputerPowers() (resp *types.PerCenterComputerPowersResp, err error) { + resp = &types.PerCenterComputerPowersResp{} + statusCode, body, err := httputils.HttpClientWithScreen(httputils.GET, "https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/percenter", strings.NewReader(``)) + if statusCode == 200 { + json.Unmarshal(body, &resp.Chart) + println(resp) + } else if statusCode != 200 { + return nil, err + } return resp, nil } diff --git a/api/internal/types/types.go b/api/internal/types/types.go index fb682586..82be107b 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -447,6 +447,32 @@ type ComputeCluster struct { Description string `json:"description"` } +type ScreenChartResp struct { + ComputingPower []int `json:"computingPower"` + CpuAvg []int `json:"cpuAvg"` + CpuLoad []int `json:"cpuLoad"` + MemoryLoad []int `json:"memoryLoad"` + MemoryAvg []int `json:"memoryAvg"` + CenterName string `json:"centerName"` +} + +type ScreenInfoResp struct { + StorageUsed float32 `json:"storageUsed"` + StorageUsing float32 `json:"storageUsing"` + UsageRate float32 `json:"usageRate"` + UsingRate float32 `json:"usingRate"` + ApiDelay string `json:"apiDelay"` + SchedulerTimes int `json:"schedulerTimes"` + SchedulerErr int `json:"schedulerErr"` + ApiTimes string `json:"apiTimes"` + CenterCount int `json:"centerCount"` + ComputingPower float64 `json:"computingPower"` + ClusterCount int `json:"clusterCount"` + RunningCount int `json:"runningCount"` + CardCount int `json:"cardCount"` + RunningTime int `json:"runningTime"` +} + type CpResp struct { POpsAtFp16 float32 `json:"pOpsAtFp16"` } @@ -2926,45 +2952,12 @@ type AiCenterInfos struct { JobCount int32 `json:"jobCount" copier:"JobCount"` } -type DailyPowerScreenReq struct { -} - type DailyPowerScreenResp struct { - TotalSize int32 `json:"totalSize" copier:"TotalSize"` - DailyComputerPowers []DailyComputerPowers `json:"dailyComputerPowers" copier:"DailyComputerPowers"` - Code int32 `json:"code,omitempty"` - Msg string `json:"msg,omitempty"` - ErrorMsg string `json:"ErrorMsg,omitempty"` -} - -type DailyComputerPowers struct { - Date string `json:"date" copier:"Date"` - ComputerPower float32 `json:"computerPower" copier:"ComputerPower"` -} - -type PerCenterComputerPowersReq struct { + Chart interface{} `json:"chart"` } type PerCenterComputerPowersResp struct { - TotalSize int32 `json:"totalSize" copier:"TotalSize"` - PerCenterComputerPowers []PerCenterComputerPowers `json:"perCenterComputerPowers" copier:"PerCenterComputerPowers"` - AccOtJobInfo AccOtJobInfo `json:"accOtJobInfo" copier:"AccOtJobInfo"` - Code int32 `json:"code,omitempty"` - Msg string `json:"msg,omitempty"` - ErrorMsg string `json:"ErrorMsg,omitempty"` -} - -type PerCenterComputerPowers struct { - CenterName string `json:"centerName" copier:"CenterName"` - ComputerPower float32 `json:"computerPower" copier:"ComputerPower"` - JobCount int32 `json:"jobCount" copier:"JobCount"` - CenterId string `json:"centerId" copier:"CenterId"` -} - -type AccOtJobInfo struct { - AccRunSec int32 `json:"accRunSec" copier:"AccRunSec"` - AccCardRunSec float32 `json:"accCardRunSec" copier:"AccCardRunSec"` - AccOtJobNum int32 `json:"accOtJobNum" copier:"AccOtJobNum"` + Chart interface{} `json:"chart"` } type UploadImageReq struct { diff --git a/deploy/pcm.sql b/deploy/pcm.sql index 70d6e42f..0904803e 100644 --- a/deploy/pcm.sql +++ b/deploy/pcm.sql @@ -945,4 +945,86 @@ CREATE TABLE `vm_openstack_overview` ( -- Records of vm_openstack_overview -- ---------------------------- +DROP TABLE IF EXISTS `screen`; +CREATE TABLE `screen` ( + `id` bigint NOT NULL COMMENT 'id', + `storage_used` float NULL DEFAULT NULL, + `storage_using` float NULL DEFAULT NULL, + `api_delay` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, + `scheduler_times` int NULL DEFAULT NULL, + `scheduler_err` int NULL DEFAULT NULL, + `api_times` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, + `center_count` int NULL DEFAULT NULL, + `computing_power` float NULL DEFAULT NULL, + `cluster_count` int NULL DEFAULT NULL, + `running_count` int NULL DEFAULT NULL, + `card_count` int NULL DEFAULT NULL, + `running_time` int NULL DEFAULT NULL, + `using_rate` float NULL DEFAULT NULL, + `usage_rate` float NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of screen +-- ---------------------------- +INSERT INTO `screen` VALUES (1, 621.3, 163.8, '2.71', 5, 1, '1.71', 34, 112.08, 48, 138633, 478568, 138633, 0.209, 0.791); + +DROP TABLE IF EXISTS `screen_domain`; +CREATE TABLE `screen_domain` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id', + `domain_id` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '资源域id', + `domain_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '资源域名称', + `job_count` int NULL DEFAULT NULL COMMENT '资源域任务数量', + `domain_source` tinyint(1) NOT NULL DEFAULT 0 COMMENT '资源域数据来源:0-nudt,1-鹏城', + `stack` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '技术栈', + `resource_type` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '资源类型', + `cpu_usage` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, + `cpu_total` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'cpu', + `memory_usage` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, + `memory_total` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '内存', + `disk_usage` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, + `disk_total` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '存储', + `node_usage` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, + `node_total` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '节点数量', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '数据创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '数据更新时间', + `delete_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否删除 0:未删除,1:已经删除', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1403 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '域资源信息' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of screen_domain +-- ---------------------------- +INSERT INTO `screen_domain` VALUES (1387, 'cloudbrain1', '鹏城云脑一号GPU计算中心', 0, 1, ' ', '智算中心', '12', '1160', '0.12', '129', '0.68', '10', '0.16', '12', '2023-08-19 20:50:02', '2023-08-19 20:50:02', 0); +INSERT INTO `screen_domain` VALUES (1388, 'xian-2', '寒武纪西安智算', 0, 1, ' ', '智算中心', '62', '2130', '0.23', '129', '0.38', '10', '0.66', '18', '2023-08-19 20:50:02', '2023-08-19 20:50:02', 0); +INSERT INTO `screen_domain` VALUES (1389, 'cloudbrain2', '云脑二号智算', 6, 1, ' ', '智算中心', '12', '9528', '0.22', '955', '0.55', '64', '0.3', '10', '2023-08-19 20:50:03', '2023-08-19 20:50:03', 0); +INSERT INTO `screen_domain` VALUES (1390, 'wuhan', '武汉智算', 720, 1, ' ', '智算中心', '87', '9216', '0.58', '40', '0.36', '6', '0.33', '3', '2023-08-19 20:50:03', '2023-08-19 20:50:03', 0); +INSERT INTO `screen_domain` VALUES (1391, 'pku', '北京大学GPU智算', 0, 1, ' ', '智算中心', '54', '2240', '0.27', '11', '0.28', '1', '0.5', '22', '2023-08-19 20:50:03', '2023-08-19 20:50:03', 0); +INSERT INTO `screen_domain` VALUES (1392, 'hefei', '中科类脑GPU智算', 388, 1, ' ', '智算中心', '23', '1952', '0.32', '22', '0.63', '14', '0.5', '12', '2023-08-19 20:50:03', '2023-08-19 20:50:03', 0); +INSERT INTO `screen_domain` VALUES (1393, 'hefei-1', '寒武纪合肥智算', 0, 1, ' ', '智算中心', '13', '1952', '0.33', '11', '0.36', '14', '0.57', '19', '2023-08-19 20:50:03', '2023-08-19 20:50:03', 0); +INSERT INTO `screen_domain` VALUES (1394, 'xian', '西安智算', 1472, 1, ' ', '智算中心', '45', '2304', '0.12', '96', '0.78', '7', '0.2', '5', '2023-08-19 20:50:03', '2023-08-19 20:50:03', 0); +INSERT INTO `screen_domain` VALUES (1395, 'xuchang', '中原智算', 2136, 1, ' ', '智算中心', '28', '7680', '0.11', '32', '0.85', '6', '0.52', '23', '2023-08-19 20:50:03', '2023-08-19 20:50:03', 0); + +DROP TABLE IF EXISTS `screen_chart`; +CREATE TABLE `screen_chart` ( + `id` int NOT NULL AUTO_INCREMENT, + `cpu_avg` int NULL DEFAULT NULL, + `cpu_load` int NULL DEFAULT NULL, + `memory_load` int NULL DEFAULT NULL, + `memory_avg` int NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of screen_chart +-- ---------------------------- +INSERT INTO `screen_chart` VALUES (1, 20, 64, 128, 62); +INSERT INTO `screen_chart` VALUES (2, 75, 64, 256, 36); +INSERT INTO `screen_chart` VALUES (3, 73, 128, 128, 73); +INSERT INTO `screen_chart` VALUES (4, 63, 72, 64, 23); +INSERT INTO `screen_chart` VALUES (5, 38, 80, 256, 35); +INSERT INTO `screen_chart` VALUES (6, 26, 40, 64, 18); +INSERT INTO `screen_chart` VALUES (7, 36, 68, 128, 39); + SET FOREIGN_KEY_CHECKS = 1;