feat: Redis热数据+K线聚合+Dashboard MySQL指标修复
This commit is contained in:
1 parent
b8b1a3d5f6
commit
a843ab7b00
9 files changed
+311
-12
No files matched your search
@@ -4,6 +4,7 @@ import (
|
||||
"ezops/internal/api/handlers"
|
||||
"ezops/internal/api/middleware"
|
||||
"ezops/internal/config"
|
||||
ezredis "ezops/pkg/redis"
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -63,6 +64,9 @@ func Register(r *gin.Engine, db *gorm.DB, log *zap.Logger, cfg *config.Config, c
|
||||
api.POST("/auth/login", authHandler.Login)
|
||||
api.POST("/auth/register", authHandler.Register)
|
||||
|
||||
// Agent 安装处理器(在 servers 和 agent 路由中共享)
|
||||
agentInstallHandler := handlers.NewAgentInstallHandler(db)
|
||||
|
||||
// 需要认证的路由
|
||||
authorized := api.Group("")
|
||||
authorized.Use(middleware.JWTAuth(&cfg.JWT))
|
||||
@@ -139,12 +143,8 @@ func Register(r *gin.Engine, db *gorm.DB, log *zap.Logger, cfg *config.Config, c
|
||||
servers.POST("/batch", serverHandler.BatchCreateServers)
|
||||
|
||||
// Agent 远程安装 // Logan.Li
|
||||
agentInstallHandler := handlers.NewAgentInstallHandler(db)
|
||||
servers.POST("/:id/install-agent", agentInstallHandler.InstallAgent)
|
||||
servers.POST("/install-agent", agentInstallHandler.BatchInstallAgent)
|
||||
|
||||
// Agent 远程命令执行
|
||||
agentGroup.POST("/exec", agentInstallHandler.RemoteExec)
|
||||
}
|
||||
|
||||
// 云账号路由
|
||||
@@ -413,19 +413,23 @@ func Register(r *gin.Engine, db *gorm.DB, log *zap.Logger, cfg *config.Config, c
|
||||
}
|
||||
|
||||
// Agent 上报路由(无需 JWT)
|
||||
agentHandler := handlers.NewAgentHandler(db)
|
||||
redisCache, _ := cache.(ezredis.Cache)
|
||||
agentHandler := handlers.NewAgentHandler(db, redisCache)
|
||||
taskHandler := handlers.NewAgentTaskHandler(db)
|
||||
agentGroup := api.Group("/agent")
|
||||
{
|
||||
agentGroup.POST("/report", agentHandler.ReceiveReport)
|
||||
agentGroup.GET("/tasks/poll", taskHandler.PollTasks)
|
||||
agentGroup.POST("/tasks/:task_id/result", taskHandler.SubmitResult)
|
||||
agentGroup.POST("/aggregate", agentHandler.AggregateMetrics)
|
||||
agentGroup.POST("/exec", agentInstallHandler.RemoteExec)
|
||||
}
|
||||
// Agent 数据查询 + 任务管理(需要 JWT)
|
||||
agentQuery := authorized.Group("/agent")
|
||||
{
|
||||
agentQuery.GET("/latest", agentHandler.GetLatestReports)
|
||||
agentQuery.GET("/history/:hostname", agentHandler.GetHostHistory)
|
||||
agentQuery.GET("/kline", agentHandler.GetKline)
|
||||
|
||||
// 远程任务
|
||||
agentQuery.POST("/tasks", taskHandler.CreateTask)
|
||||
|
||||
Reference in new issue
Block a user