fix: dashboard metrics 慢查询优化(index+UNIX_TIMESTAMP分组) + 批量升级版本号修复

This commit is contained in:
attacker committed 2026-06-24 14:27:58 +00:00
1 parent c515f6ed03
commit 20f64e3851
5 files changed
+222 -19

No files matched your search

+11 -4
View File
@@ -6,6 +6,7 @@ import (
"net"
"net/http"
"strconv"
"strings"
"time"
"ezops/internal/models"
@@ -423,9 +424,9 @@ func (h *AgentInstallHandler) BatchUpgradeAgent(c *gin.Context) {
binaryFile = "aiops-agent-linux-arm64"
}
// 下载新二进制 + 重启服务
// 下载新二进制 + 获取版本号 + 重启服务
upgradeScript := fmt.Sprintf(
`curl -fsSL -o /tmp/aiops-agent %s/api/agent/bin/%s && chmod +x /tmp/aiops-agent && systemctl stop aiops-agent 2>/dev/null; mv /tmp/aiops-agent /usr/local/bin/aiops-agent && systemctl start aiops-agent && echo "UPGRADE_OK"`,
`curl -fsSL -o /tmp/aiops-agent %s/api/agent/bin/%s && chmod +x /tmp/aiops-agent && systemctl stop aiops-agent 2>/dev/null; mv /tmp/aiops-agent /usr/local/bin/aiops-agent && systemctl start aiops-agent; ver=$(/usr/local/bin/aiops-agent output 2>/dev/null | grep 'agent.version' | awk -F'[|[|]' '{print $2}' | tr -d ' '); echo "UPGRADE_OK ver=$ver"`,
serverURL, binaryFile,
)
@@ -437,9 +438,15 @@ func (h *AgentInstallHandler) BatchUpgradeAgent(c *gin.Context) {
continue
}
// 更新版本号
// 从输出提取版本号
agentVersion := "unknown"
parts := strings.Split(out, "ver=")
if len(parts) > 1 {
agentVersion = strings.TrimSpace(parts[1])
}
h.db.Model(&server).Updates(map[string]interface{}{
"agent_version": "v0.1.0",
"agent_version": agentVersion,
"last_check_at": time.Now(),
})
log.Printf("[BatchUpgrade] %s Agent 升级成功", server.Hostname)