style: 监控信息接口

This commit is contained in:
TsMask
2024-08-15 09:38:41 +08:00
parent 1b1c15995d
commit cf1dbf4a0e
2 changed files with 10 additions and 16 deletions

View File

@@ -28,21 +28,14 @@ type MonitorController struct {
func (s *MonitorController) Load(c *gin.Context) {
language := ctx.AcceptLanguage(c)
var querys struct {
// 数据类型all/load/cpu/memory/io/network
Type string `form:"type" binding:"required,oneof=all load cpu memory io network"`
// 开始时间
StartTime int64 `form:"startTime" binding:"required"`
// 结束时间
EndTime int64 `form:"endTime" binding:"required"`
// 网元类型
NeType string `form:"neType"`
// 网元ID
NeID string `form:"neId"`
// 名称networ和iok时有效
Name string `form:"name"`
Type string `form:"type" binding:"required,oneof=all load cpu memory io network"` // 数据类型all/load/cpu/memory/io/network
StartTime int64 `form:"startTime" binding:"required"` // 开始时间
EndTime int64 `form:"endTime" binding:"required"` // 结束时间
NeType string `form:"neType"` // 网元类型
NeID string `form:"neId"` // 网元ID
Name string `form:"name"` // 名称networ和io时有效
}
err := c.ShouldBindQuery(&querys)
if err != nil {
if err := c.ShouldBindQuery(&querys); err != nil {
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
return
}

View File

@@ -24,12 +24,13 @@ type SystemInfoController struct {
//
// GET /
func (s *SystemInfoController) Info(c *gin.Context) {
c.JSON(200, result.OkData(map[string]any{
data := map[string]any{
"cpu": s.systemInfogService.CPUInfo(),
"memory": s.systemInfogService.MemoryInfo(),
"network": s.systemInfogService.NetworkInfo(),
"time": s.systemInfogService.TimeInfo(),
"system": s.systemInfogService.SystemInfo(),
"disk": s.systemInfogService.DiskInfo(),
}))
}
c.JSON(200, result.OkData(data))
}