告警中心 - 新增统一告警(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>
185 lines
6.4 KiB
Go
185 lines
6.4 KiB
Go
// Package dto 定义请求(Request)与响应(Response)传输对象
|
|
// 与 models 分离:models 是 GORM 表结构,dto 是 API 契约
|
|
package dto
|
|
|
|
import "time"
|
|
|
|
// ━━━ Server ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
|
|
// CreateServerRequest 创建服务器
|
|
type CreateServerRequest struct {
|
|
Hostname string `json:"hostname" binding:"required"`
|
|
IP string `json:"ip" binding:"required"`
|
|
PublicIP string `json:"public_ip"`
|
|
Port int `json:"port"`
|
|
Username string `json:"username"`
|
|
Password string `json:"password"`
|
|
SSHKey string `json:"ssh_key"`
|
|
AuthType string `json:"auth_type"`
|
|
OS string `json:"os"`
|
|
OSVersion string `json:"os_version"`
|
|
Arch string `json:"arch"`
|
|
CPU int `json:"cpu"`
|
|
Memory int64 `json:"memory"`
|
|
Disk int64 `json:"disk"`
|
|
RegionID *uint `json:"region_id"`
|
|
CloudID *uint `json:"cloud_id"`
|
|
Tags string `json:"tags"`
|
|
Description string `json:"description"`
|
|
}
|
|
|
|
// UpdateServerRequest 更新服务器 — 部分更新 (使用 map)
|
|
type UpdateServerRequest struct {
|
|
Hostname *string `json:"hostname"`
|
|
IP *string `json:"ip"`
|
|
PublicIP *string `json:"public_ip"`
|
|
Port *int `json:"port"`
|
|
Username *string `json:"username"`
|
|
Password *string `json:"password"`
|
|
SSHKey *string `json:"ssh_key"`
|
|
AuthType *string `json:"auth_type"`
|
|
OS *string `json:"os"`
|
|
OSVersion *string `json:"os_version"`
|
|
Arch *string `json:"arch"`
|
|
CPU *int `json:"cpu"`
|
|
Memory *int64 `json:"memory"`
|
|
Disk *int64 `json:"disk"`
|
|
Status *string `json:"status"`
|
|
CPUUsage *float64 `json:"cpu_usage"`
|
|
MemoryUsage *float64 `json:"memory_usage"`
|
|
DiskUsage *float64 `json:"disk_usage"`
|
|
RegionID *uint `json:"region_id"`
|
|
CloudID *uint `json:"cloud_id"`
|
|
Tags *string `json:"tags"`
|
|
Description *string `json:"description"`
|
|
}
|
|
|
|
// ServerListItem 服务器列表项 (精简)
|
|
type ServerListItem struct {
|
|
ID uint `json:"id"`
|
|
Hostname string `json:"hostname"`
|
|
IP string `json:"ip"`
|
|
Status string `json:"status"`
|
|
CPUUsage float64 `json:"cpu_usage"`
|
|
MemoryUsage float64 `json:"memory_usage"`
|
|
DiskUsage float64 `json:"disk_usage"`
|
|
AgentStatus string `json:"agent_status"`
|
|
AgentVersion string `json:"agent_version"`
|
|
HasAuth bool `json:"has_auth"`
|
|
OS string `json:"os"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// ━━━ Credential ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
|
|
// CreateCredentialRequest 创建凭据
|
|
type CreateCredentialRequest struct {
|
|
Name string `json:"name" binding:"required"`
|
|
SecretType string `json:"secret_type" binding:"required"` // ssh, docker, tls, password, env
|
|
Description string `json:"description"`
|
|
|
|
// SSH
|
|
SSHPrivateKey string `json:"ssh_private_key"`
|
|
SSHPublicKey string `json:"ssh_public_key"`
|
|
SSHUser string `json:"ssh_user"`
|
|
SSHPort int `json:"ssh_port"`
|
|
SSHPassword string `json:"ssh_password"`
|
|
|
|
// Docker
|
|
DockerServer string `json:"docker_server"`
|
|
DockerUsername string `json:"docker_username"`
|
|
DockerPassword string `json:"docker_password"`
|
|
|
|
// TLS
|
|
TLSCert string `json:"tls_cert"`
|
|
TLSKey string `json:"tls_key"`
|
|
TLSCA string `json:"tls_ca"`
|
|
|
|
// Password / Generic
|
|
PlainPassword string `json:"plain_password"`
|
|
|
|
// Env
|
|
EnvVars string `json:"env_vars"`
|
|
}
|
|
|
|
// UpdateCredentialRequest 更新凭据
|
|
type UpdateCredentialRequest struct {
|
|
Name *string `json:"name"`
|
|
Description *string `json:"description"`
|
|
|
|
SSHPrivateKey *string `json:"ssh_private_key"`
|
|
SSHPublicKey *string `json:"ssh_public_key"`
|
|
SSHUser *string `json:"ssh_user"`
|
|
SSHPort *int `json:"ssh_port"`
|
|
SSHPassword *string `json:"ssh_password"`
|
|
|
|
DockerServer *string `json:"docker_server"`
|
|
DockerUsername *string `json:"docker_username"`
|
|
DockerPassword *string `json:"docker_password"`
|
|
|
|
TLSCert *string `json:"tls_cert"`
|
|
TLSKey *string `json:"tls_key"`
|
|
TLSCA *string `json:"tls_ca"`
|
|
|
|
PlainPassword *string `json:"plain_password"`
|
|
EnvVars *string `json:"env_vars"`
|
|
}
|
|
|
|
// ━━━ Alert ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
|
|
// CreateAlertContactRequest 创建告警联系人
|
|
type CreateAlertContactRequest struct {
|
|
Name string `json:"name" binding:"required"`
|
|
ChannelType string `json:"channel_type" binding:"required"` // feishu, dingtalk, wechat, webhook
|
|
WebhookURL string `json:"webhook_url" binding:"required"`
|
|
Phone string `json:"phone"`
|
|
Email string `json:"email"`
|
|
}
|
|
|
|
// UpdateAlertContactRequest 更新告警联系人
|
|
type UpdateAlertContactRequest struct {
|
|
Name *string `json:"name"`
|
|
ChannelType *string `json:"channel_type"`
|
|
WebhookURL *string `json:"webhook_url"`
|
|
Phone *string `json:"phone"`
|
|
Email *string `json:"email"`
|
|
}
|
|
|
|
// CreateAlertContactGroupRequest 创建告警联系组 // Logan.Li
|
|
type CreateAlertContactGroupRequest struct {
|
|
GroupName string `json:"group_name" binding:"required"`
|
|
Notes string `json:"notes"`
|
|
ContactIDs []uint `json:"contact_ids"`
|
|
}
|
|
|
|
// UpdateAlertContactGroupRequest 更新告警联系组 // Logan.Li
|
|
type UpdateAlertContactGroupRequest struct {
|
|
GroupName *string `json:"group_name"`
|
|
Notes *string `json:"notes"`
|
|
ContactIDs *[]uint `json:"contact_ids"`
|
|
}
|
|
|
|
// CreateAlertRuleRequest 创建告警规则
|
|
type CreateAlertRuleRequest struct {
|
|
Name string `json:"name" binding:"required"`
|
|
Metric string `json:"metric" binding:"required"`
|
|
Condition string `json:"condition" binding:"required"` // >, <, >=, <=, ==
|
|
Threshold float64 `json:"threshold" binding:"required"`
|
|
Duration string `json:"duration"` // 30s, 1m, 5m
|
|
ContactIDs []uint `json:"contact_ids"`
|
|
Enabled bool `json:"enabled"`
|
|
Description string `json:"description"`
|
|
}
|
|
|
|
// UpdateAlertRuleRequest 更新告警规则
|
|
type UpdateAlertRuleRequest struct {
|
|
Name *string `json:"name"`
|
|
Metric *string `json:"metric"`
|
|
Condition *string `json:"condition"`
|
|
Threshold *float64 `json:"threshold"`
|
|
Duration *string `json:"duration"`
|
|
ContactIDs *[]uint `json:"contact_ids"`
|
|
Enabled *bool `json:"enabled"`
|
|
Description *string `json:"description"`
|
|
}
|