Files
EasyGoAdmin_GoFrame_EleVue/api/v1/server_monitor.go
T
2026-10-20 11:37:25 +08:00

73 lines
2.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package v1
import (
"github.com/gogf/gf/v2/util/gmeta"
)
// ============================== 服务器监控模块 ==============================
// ServerInfoReq 查询服务器信息请求
type ServerInfoReq struct {
gmeta.Meta `method:"get" path:"/api/server/info" summary:"服务器监控信息" log:"服务器监控-查询信息" logType:"query"`
}
// ServerOsInfo 操作系统与进程信息
type ServerOsInfo struct {
Hostname string `json:"hostname"` // 主机名
GoVersion string `json:"goVersion"` // Go 运行时版本
Arch string `json:"arch"` // 架构
NumCPU int `json:"numCpu"` // CPU 核数
Goroutines int `json:"goroutines"` // 协程数
Uptime string `json:"uptime"` // 进程运行时长
}
// ServerMemInfo 进程内存信息(MB)
type ServerMemInfo struct {
AllocMB float64 `json:"allocMb"` // 已分配
TotalAllocMB float64 `json:"totalAllocMb"` // 累计分配
SysMB float64 `json:"sysMb"` // 系统占用
HeapAllocMB float64 `json:"heapAllocMb"` // 堆已分配
HeapSysMB float64 `json:"heapSysMb"` // 堆系统占用
HeapObjects uint64 `json:"heapObjects"` // 堆对象数
GCCycles uint32 `json:"gcCycles"` // GC 次数
}
// ServerDiskInfo 磁盘分区信息
type ServerDiskInfo struct {
Path string `json:"path"` // 路径(工作目录所在分区)
TotalGB float64 `json:"totalGb"` // 总容量(GB)
FreeGB float64 `json:"freeGb"` // 可用容量(GB)
UsedPercent float64 `json:"usedPercent"` // 使用率(%)
}
// ServerDbInfo 数据库连通信息
type ServerDbInfo struct {
Version string `json:"version"` // 数据库版本
PingMs int64 `json:"pingMs"` // 连通耗时(毫秒)
}
// ServerCacheBrief 缓存连通信息
type ServerCacheBrief struct {
Mode string `json:"mode"` // redis / memory
Connected bool `json:"connected"` // 是否连通
}
// ServerSchedulerInfo 定时任务调度器状态
type ServerSchedulerInfo struct {
Enabled bool `json:"enabled"` // 调度器是否已启动
Healthy bool `json:"healthy"` // 是否健康(挂载数不小于应挂载数)
Mounted int `json:"mounted"` // 已挂载任务数
Expected int `json:"expected"` // 应挂载任务数(status=1)
StartTime string `json:"startTime"` // 调度器启动时间
}
// ServerInfoRes 服务器监控信息结果
type ServerInfoRes struct {
Server ServerOsInfo `json:"server"` // 操作系统与进程
Mem ServerMemInfo `json:"mem"` // 内存
Disk []ServerDiskInfo `json:"disk"` // 磁盘
Db ServerDbInfo `json:"db"` // 数据库
Cache ServerCacheBrief `json:"cache"` // 缓存
Scheduler ServerSchedulerInfo `json:"scheduler"` // 定时任务调度器
}