package model import "time" // AgentSetting Agent 采集策略。 // // Hostname 为空串表示全局默认,非空表示对单台主机的覆盖; // 平台改这里即可下发新的采集/上报频率,Agent 侧热更新 ticker,无需重装。 // Logan.Li type AgentSetting struct { ID uint `gorm:"primarykey" json:"id"` Hostname string `gorm:"size:255;uniqueIndex:uniq_agent_settings_hostname;not null;default:''" json:"hostname"` ReportInterval int `gorm:"not null;default:10" json:"report_interval"` // 采集上报间隔(秒) ConfigPollInterval int `gorm:"not null;default:30" json:"config_poll_interval"` // 配置轮询间隔(秒) UpdatedBy string `gorm:"size:128;not null;default:''" json:"updated_by"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } // TableName 固定表名,便于迁移脚本与代码保持一致。 // Logan.Li func (AgentSetting) TableName() string { return "monitor_agent_settings" } // AgentConfigDTO 下发给 Agent 的合并配置。 // // 原先 Agent 每 5 秒要分别请求 tasks/poll、health-probes/config、port-policy // 三个接口,请求量是上报本身的 6 倍;合并为单次响应后可显著降低平台与网络开销。 // Logan.Li type AgentConfigDTO struct { // ConfigVersion 为配置指纹,Agent 可比对后跳过后续相同配置的处理。 // Logan.Li ConfigVersion string `json:"config_version"` // ReportInterval 采集上报间隔(秒),Agent 收到后热更新 ticker。 // Logan.Li ReportInterval int `json:"report_interval"` // ConfigPollInterval 配置轮询间隔(秒)。 // Logan.Li ConfigPollInterval int `json:"config_poll_interval"` Tasks []AgentTask `json:"tasks"` HealthProbes []HealthProbe `json:"health_probes"` PortPolicy *AgentPortPolicyDTO `json:"port_policy,omitempty"` }