package v2 import ( "github.com/1Panel-dev/1Panel/agent/app/api/v2/helper" "github.com/1Panel-dev/1Panel/agent/app/dto" "github.com/gin-gonic/gin" ) // @Tags Monitor // @Summary Load monitor data // @Param request body dto.MonitorSearch true "request" // @Success 200 {array} dto.MonitorData // @Security ApiKeyAuth // @Security Timestamp // @Router /hosts/monitor/search [post] func (b *BaseApi) LoadMonitor(c *gin.Context) { var req dto.MonitorSearch if err := helper.CheckBindAndValidate(&req, c); err != nil { return } data, err := monitorService.LoadMonitorData(req) if err != nil { helper.InternalServer(c, err) return } helper.SuccessWithDataGzipped(c, data) } // @Tags Monitor // @Summary Clean host or GPU monitor data // @Param request body dto.MonitorClean true "request" // @Success 200 // @Security ApiKeyAuth // @Security Timestamp // @Router /hosts/monitor/clean [post] // @x-panel-log {"bodyKeys":["type"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"清空 [type] 监控数据","formatEN":"clean [type] monitoring data"} func (b *BaseApi) CleanMonitor(c *gin.Context) { var req dto.MonitorClean if err := helper.CheckBindAndValidate(&req, c); err != nil { return } if err := monitorService.CleanData(req.Type); err != nil { helper.InternalServer(c, err) return } helper.Success(c) } // @Tags Monitor // @Summary Load monitor setting // @Success 200 {object} dto.MonitorSetting // @Security ApiKeyAuth // @Security Timestamp // @Router /hosts/monitor/setting [get] func (b *BaseApi) LoadMonitorSetting(c *gin.Context) { setting, err := monitorService.LoadSetting() if err != nil { helper.InternalServer(c, err) return } helper.SuccessWithData(c, setting) } // @Tags Monitor // @Summary Update monitor setting // @Param request body dto.MonitorSettingUpdate true "request" // @Success 200 // @Security ApiKeyAuth // @Security Timestamp // @Router /hosts/monitor/setting/update [post] // @x-panel-log {"bodyKeys":["key", "value"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改默认监控网卡 [key]-[value]","formatEN":"update default monitor [key]-[value]"} func (b *BaseApi) UpdateMonitorSetting(c *gin.Context) { var req dto.MonitorSettingUpdate if err := helper.CheckBindAndValidate(&req, c); err != nil { return } if err := monitorService.UpdateSetting(req.Key, req.Value); err != nil { helper.InternalServer(c, err) return } helper.Success(c) } // @Tags Monitor // @Summary Get network options // @Success 200 // @Security ApiKeyAuth // @Security Timestamp // @Router /hosts/monitor/netoptions [get] func (b *BaseApi) GetNetworkOptions(c *gin.Context) { helper.SuccessWithData(c, monitorService.LoadNetworkOptions()) } // @Tags Monitor // @Summary Get IO options // @Success 200 // @Security ApiKeyAuth // @Security Timestamp // @Router /hosts/monitor/iooptions [get] func (b *BaseApi) GetIOOptions(c *gin.Context) { helper.SuccessWithData(c, monitorService.LoadIOOptions()) }