mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/1Panel-dev/1Panel.git
synced 2026-09-20 08:03:55 +08:00
64 lines
1.7 KiB
Go
64 lines
1.7 KiB
Go
package v2
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/1Panel-dev/1Panel/core/app/api/v2/helper"
|
|
"github.com/1Panel-dev/1Panel/core/app/dto"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// @Tags RuntimeDiagnostics
|
|
// @Summary Load Core runtime diagnostics summary
|
|
// @Success 200 {object} dto.RuntimeDiagnosticsSummary
|
|
// @Security ApiKeyAuth
|
|
// @Security Timestamp
|
|
// @Router /core/hosts/diagnostics/summary [get]
|
|
func (b *BaseApi) LoadRuntimeDiagnosticsSummary(c *gin.Context) {
|
|
data, err := runtimeDiagnosticsService.Summary()
|
|
if err != nil {
|
|
helper.InternalServer(c, err)
|
|
return
|
|
}
|
|
helper.SuccessWithData(c, data)
|
|
}
|
|
|
|
// @Tags RuntimeDiagnostics
|
|
// @Summary Load Core grouped goroutine snapshot
|
|
// @Success 200 {object} dto.RuntimeGoroutineSnapshot
|
|
// @Security ApiKeyAuth
|
|
// @Security Timestamp
|
|
// @Router /core/hosts/diagnostics/goroutines [get]
|
|
func (b *BaseApi) LoadRuntimeGoroutines(c *gin.Context) {
|
|
data, err := runtimeDiagnosticsService.Goroutines()
|
|
if err != nil {
|
|
helper.InternalServer(c, err)
|
|
return
|
|
}
|
|
helper.SuccessWithData(c, data)
|
|
}
|
|
|
|
// @Tags RuntimeDiagnostics
|
|
// @Summary Capture Core runtime profile
|
|
// @Param request body dto.RuntimeProfileCreate true "request"
|
|
// @Success 200 {file} file
|
|
// @Security ApiKeyAuth
|
|
// @Security Timestamp
|
|
// @Router /core/hosts/diagnostics/profiles [post]
|
|
func (b *BaseApi) CreateRuntimeProfile(c *gin.Context) {
|
|
var req dto.RuntimeProfileCreate
|
|
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
|
return
|
|
}
|
|
profile, err := runtimeDiagnosticsService.CreateProfile(req)
|
|
if err != nil {
|
|
helper.BadRequest(c, err)
|
|
return
|
|
}
|
|
defer os.Remove(profile.Path)
|
|
c.Header("Content-Disposition", `attachment; filename="`+profile.Name+`"`)
|
|
c.Header("Content-Type", "application/octet-stream")
|
|
c.File(profile.Path)
|
|
c.Abort()
|
|
}
|