feat: 监控告警体系统一重构 + 自动化任务调度引擎 + 监控大屏拆分
告警中心 - 新增统一告警(alert_unified)、监控告警规则(monitor_alert_rule)、指标目录(alert_metric_catalog) - 通知策略与消息分发(alert_notify_policy/dispatch/message)、静默规则 - 告警引擎按阈值/SNMP 拆分(alert_engine_monitor/snmp) 监控采集 - SNMP 常量/模板与历史指标(snmp templates/constants、snmp_metrics_history、snmp_collect) - 中间件监控 Redis 采集与种子(middleware_monitor_redis/seed) - 站点探测 pkg(siteprobe) + 站点视图(site_view) 自动化任务 - cron 调度器(cronscheduler)、脚本运行器(scriptrunner)、系统任务(systask)及运行记录(cron_job_run、system_task) 审计与凭证 - 审计设置(audit_setting) + 历史清理(auditcleaner) 前端 - 监控页面(host/middleware/site/snmp)拆分为子模块并大屏化 - 告警中心多 Tab(规则/指标目录/通知策略/静默)、任务管理组件重构、Agent CLI Markdown 渲染 - 移除旧脚本卡片/详情/日志组件,统一为 ScriptTable/ScriptCodeEditor/TerminalOutput Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
092d0e4b9e
commit
471353e3d7
190 files changed
+16640
-3484
No files matched your search
@@ -97,16 +97,44 @@ func (h *DashboardHandler) GetStats(c *gin.Context) {
|
||||
h.db.Model(&model.KubernetesCluster{}).Where("status = ?", "warning").Count(&k8sStats.Warning)
|
||||
h.db.Model(&model.KubernetesCluster{}).Where("status = ?", "error").Count(&k8sStats.Error)
|
||||
|
||||
var totalNodes, totalPods, totalServices int64
|
||||
var totalNodes, totalPods, totalServices, totalIngresses, totalDeployments int64
|
||||
h.db.Model(&model.KubernetesNode{}).Count(&totalNodes)
|
||||
h.db.Model(&model.KubernetesPod{}).Count(&totalPods)
|
||||
h.db.Model(&model.KubernetesService{}).Count(&totalServices)
|
||||
h.db.Model(&model.KubernetesIngress{}).Count(&totalIngresses)
|
||||
h.db.Model(&model.KubernetesDeployment{}).Count(&totalDeployments)
|
||||
k8sStats.TotalNodes = totalNodes
|
||||
k8sStats.TotalPods = totalPods
|
||||
k8sStats.TotalServices = totalServices
|
||||
k8sStats.TotalIngresses = totalIngresses
|
||||
k8sStats.TotalDeployments = totalDeployments
|
||||
|
||||
stats.K8sStats = k8sStats
|
||||
|
||||
today := time.Now().Format("2006-01-02")
|
||||
|
||||
// 自动化运维统计 // Logan.Li
|
||||
var automationStats model.AutomationStats
|
||||
h.db.Model(&model.CronJob{}).Count(&automationStats.CronJobCount)
|
||||
h.db.Model(&model.Script{}).Count(&automationStats.ScriptCount)
|
||||
h.db.Model(&model.TaskExecution{}).Where("DATE(created_at) = ?", today).Count(&automationStats.TodayExecutions)
|
||||
var successExec, totalExec int64
|
||||
h.db.Model(&model.TaskExecution{}).Where("status = ?", "success").Count(&successExec)
|
||||
h.db.Model(&model.TaskExecution{}).Count(&totalExec)
|
||||
if totalExec > 0 {
|
||||
automationStats.SuccessRate = math.Round(float64(successExec)/float64(totalExec)*10000) / 100
|
||||
}
|
||||
stats.AutomationStats = automationStats
|
||||
|
||||
// 运维概览:拨测 / 中间件 / SNMP // Logan.Li
|
||||
var opsStats model.OpsOverviewStats
|
||||
h.db.Model(&model.Domain{}).Count(&opsStats.DomainCount)
|
||||
h.db.Model(&model.SiteTask{}).Count(&opsStats.SiteTaskCount)
|
||||
h.db.Model(&model.MonitorTarget{}).Where("description IN ?", []string{"redis", "mysql"}).Count(&opsStats.MiddlewareCount)
|
||||
h.db.Model(&model.SNMPDevice{}).Count(&opsStats.SnmpDeviceCount)
|
||||
h.db.Model(&model.MonitorTarget{}).Count(&opsStats.MonitorTargetCount)
|
||||
stats.OpsStats = opsStats
|
||||
|
||||
// 告警统计
|
||||
var alertStats model.AlertStats
|
||||
h.db.Model(&model.AlertEvent{}).Count(&alertStats.Total)
|
||||
@@ -117,7 +145,6 @@ func (h *DashboardHandler) GetStats(c *gin.Context) {
|
||||
h.db.Model(&model.AlertEvent{}).Where("severity = ?", "info").Count(&alertStats.Info)
|
||||
|
||||
// 今日告警
|
||||
today := time.Now().Format("2006-01-02")
|
||||
h.db.Model(&model.AlertEvent{}).Where("DATE(created_at) = ?", today).Count(&alertStats.TodayCount)
|
||||
|
||||
// 本周告警
|
||||
|
||||
Reference in new issue
Block a user