fix
This commit is contained in:
@@ -2,18 +2,30 @@ package models
|
||||
|
||||
import "time"
|
||||
|
||||
// LogEvent 表示一条归一化/存储后的日志事件。
|
||||
type LogEvent struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
SourceKind string `gorm:"size:16;index" json:"source_kind"`
|
||||
RemoteAddr string `gorm:"size:64" json:"remote_addr"`
|
||||
RawPayload string `gorm:"type:text" json:"raw_payload"`
|
||||
NormalizedSummary string `gorm:"type:text" json:"normalized_summary"`
|
||||
NormalizedDetail string `gorm:"type:text" json:"normalized_detail"`
|
||||
DeviceName string `gorm:"size:512;index" json:"device_name"`
|
||||
SeverityCode string `gorm:"size:32" json:"severity_code"`
|
||||
TrapOID string `gorm:"size:512;index" json:"trap_oid"`
|
||||
AlertSent bool `json:"alert_sent"`
|
||||
// ID 是数据库主键。
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
// CreatedAt 记录创建时间(写入日志事件时)。
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
// SourceKind 表示日志来源类型(例如 trap/syslog 等)。
|
||||
SourceKind string `gorm:"size:16;index" json:"source_kind"`
|
||||
// RemoteAddr 表示日志发送方地址。
|
||||
RemoteAddr string `gorm:"size:64" json:"remote_addr"`
|
||||
// RawPayload 保存原始负载内容。
|
||||
RawPayload string `gorm:"type:text" json:"raw_payload"`
|
||||
// NormalizedSummary 保存归一化后的摘要信息。
|
||||
NormalizedSummary string `gorm:"type:text" json:"normalized_summary"`
|
||||
// NormalizedDetail 保存归一化后的详细信息。
|
||||
NormalizedDetail string `gorm:"type:text" json:"normalized_detail"`
|
||||
// DeviceName 表示关联设备名称。
|
||||
DeviceName string `gorm:"size:512;index" json:"device_name"`
|
||||
// SeverityCode 表示告警/严重度编码。
|
||||
SeverityCode string `gorm:"size:32" json:"severity_code"`
|
||||
// TrapOID 表示关联的 Trap OID(若来源为 trap)。
|
||||
TrapOID string `gorm:"size:512;index" json:"trap_oid"`
|
||||
// AlertSent 表示是否已将告警发送出去。
|
||||
AlertSent bool `json:"alert_sent"`
|
||||
}
|
||||
|
||||
func (LogEvent) TableName() string {
|
||||
|
||||
@@ -2,18 +2,30 @@ package models
|
||||
|
||||
import "time"
|
||||
|
||||
// SyslogRule 表示一条 Syslog 规则,用于匹配设备日志并触发告警。
|
||||
type SyslogRule struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Name string `gorm:"size:256" json:"name"`
|
||||
Enabled bool `gorm:"default:true" json:"enabled"`
|
||||
Priority int `gorm:"index" json:"priority"`
|
||||
DeviceNameContains string `gorm:"size:512" json:"device_name_contains"`
|
||||
KeywordRegex string `gorm:"size:512" json:"keyword_regex"`
|
||||
AlertName string `gorm:"size:256" json:"alert_name"`
|
||||
SeverityCode string `gorm:"size:32" json:"severity_code"`
|
||||
PolicyID uint `json:"policy_id"`
|
||||
// ID 是数据库主键。
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
// CreatedAt 记录创建时间(GORM 自动维护)。
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
// UpdatedAt 记录更新时间(GORM 自动维护)。
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
// Name 规则名称,用于展示/标识。
|
||||
Name string `gorm:"size:256" json:"name"`
|
||||
// Enabled 表示该规则是否启用。
|
||||
Enabled bool `gorm:"default:true" json:"enabled"`
|
||||
// Priority 表示匹配优先级(数值越高/低需以业务约定为准)。
|
||||
Priority int `gorm:"index" json:"priority"`
|
||||
// DeviceNameContains 表示设备名称包含条件。
|
||||
DeviceNameContains string `gorm:"size:512" json:"device_name_contains"`
|
||||
// KeywordRegex 表示关键字/内容匹配的正则表达式。
|
||||
KeywordRegex string `gorm:"size:512" json:"keyword_regex"`
|
||||
// AlertName 表示告警名称。
|
||||
AlertName string `gorm:"size:256" json:"alert_name"`
|
||||
// SeverityCode 表示严重级别编码。
|
||||
SeverityCode string `gorm:"size:32" json:"severity_code"`
|
||||
// PolicyID 表示关联的告警/处理策略 ID。
|
||||
PolicyID uint `json:"policy_id"`
|
||||
}
|
||||
|
||||
func (SyslogRule) TableName() string {
|
||||
|
||||
@@ -2,16 +2,26 @@ package models
|
||||
|
||||
import "time"
|
||||
|
||||
// TrapDictionaryEntry 表示 Trap 字典条目,用于描述某个 OID 前缀对应的告警元信息。
|
||||
type TrapDictionaryEntry struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
OIDPrefix string `gorm:"size:512;uniqueIndex" json:"oid_prefix"`
|
||||
Title string `gorm:"size:512" json:"title"`
|
||||
Description string `gorm:"type:text" json:"description"`
|
||||
SeverityCode string `gorm:"size:32" json:"severity_code"`
|
||||
RecoveryMessage string `gorm:"type:text" json:"recovery_message"`
|
||||
Enabled bool `gorm:"default:true" json:"enabled"`
|
||||
// ID 是数据库主键。
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
// CreatedAt 记录创建时间(GORM 自动维护)。
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
// UpdatedAt 记录更新时间(GORM 自动维护)。
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
// OIDPrefix 表示该字典条目对应的 OID 前缀(唯一)。
|
||||
OIDPrefix string `gorm:"size:512;uniqueIndex" json:"oid_prefix"`
|
||||
// Title 表示字典条目的标题。
|
||||
Title string `gorm:"size:512" json:"title"`
|
||||
// Description 表示字典条目的说明文本。
|
||||
Description string `gorm:"type:text" json:"description"`
|
||||
// SeverityCode 表示默认严重级别编码。
|
||||
SeverityCode string `gorm:"size:32" json:"severity_code"`
|
||||
// RecoveryMessage 表示恢复/消警时的消息模板内容。
|
||||
RecoveryMessage string `gorm:"type:text" json:"recovery_message"`
|
||||
// Enabled 表示该字典条目是否启用。
|
||||
Enabled bool `gorm:"default:true" json:"enabled"`
|
||||
}
|
||||
|
||||
func (TrapDictionaryEntry) TableName() string {
|
||||
|
||||
@@ -2,18 +2,30 @@ package models
|
||||
|
||||
import "time"
|
||||
|
||||
// TrapRule 表示一条 SNMP Trap 规则,用于匹配并触发告警策略。
|
||||
type TrapRule struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Name string `gorm:"size:256" json:"name"`
|
||||
Enabled bool `gorm:"default:true" json:"enabled"`
|
||||
Priority int `gorm:"index" json:"priority"`
|
||||
OIDPrefix string `gorm:"size:512" json:"oid_prefix"`
|
||||
VarbindMatchRegex string `gorm:"size:512" json:"varbind_match_regex"`
|
||||
AlertName string `gorm:"size:256" json:"alert_name"`
|
||||
SeverityCode string `gorm:"size:32" json:"severity_code"`
|
||||
PolicyID uint `json:"policy_id"`
|
||||
// ID 是数据库主键。
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
// CreatedAt 记录创建时间(GORM 自动维护)。
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
// UpdatedAt 记录更新时间(GORM 自动维护)。
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
// Name 规则名称,用于展示/标识。
|
||||
Name string `gorm:"size:256" json:"name"`
|
||||
// Enabled 表示该规则是否启用。
|
||||
Enabled bool `gorm:"default:true" json:"enabled"`
|
||||
// Priority 表示匹配优先级(数值越高/低需以业务约定为准)。
|
||||
Priority int `gorm:"index" json:"priority"`
|
||||
// OIDPrefix 表示匹配的 OID 前缀。
|
||||
OIDPrefix string `gorm:"size:512" json:"oid_prefix"`
|
||||
// VarbindMatchRegex 表示对 varbind 内容的正则匹配条件。
|
||||
VarbindMatchRegex string `gorm:"size:512" json:"varbind_match_regex"`
|
||||
// AlertName 表示告警名称。
|
||||
AlertName string `gorm:"size:256" json:"alert_name"`
|
||||
// SeverityCode 表示严重级别编码。
|
||||
SeverityCode string `gorm:"size:32" json:"severity_code"`
|
||||
// PolicyID 表示关联的告警/处理策略 ID。
|
||||
PolicyID uint `json:"policy_id"`
|
||||
}
|
||||
|
||||
func (TrapRule) TableName() string {
|
||||
|
||||
@@ -2,16 +2,26 @@ package models
|
||||
|
||||
import "time"
|
||||
|
||||
// TrapShield 表示一条针对 SNMP Trap 的“屏蔽/防护”规则。
|
||||
type TrapShield struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Name string `gorm:"size:256" json:"name"`
|
||||
Enabled bool `gorm:"default:true" json:"enabled"`
|
||||
SourceIPCIDR string `gorm:"size:64" json:"source_ip_cidr"`
|
||||
OIDPrefix string `gorm:"size:512" json:"oid_prefix"`
|
||||
InterfaceHint string `gorm:"size:256" json:"interface_hint"`
|
||||
TimeWindowsJSON string `gorm:"type:text" json:"time_windows_json"`
|
||||
// ID 是数据库主键。
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
// CreatedAt 记录创建时间(GORM 自动维护)。
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
// UpdatedAt 记录更新时间(GORM 自动维护)。
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
// Name 规则名称,用于展示/标识。
|
||||
Name string `gorm:"size:256" json:"name"`
|
||||
// Enabled 表示该规则是否启用。
|
||||
Enabled bool `gorm:"default:true" json:"enabled"`
|
||||
// SourceIPCIDR 表示规则适用的源 IP 网段(CIDR)。
|
||||
SourceIPCIDR string `gorm:"size:64" json:"source_ip_cidr"`
|
||||
// OIDPrefix 表示匹配的 OID 前缀。
|
||||
OIDPrefix string `gorm:"size:512" json:"oid_prefix"`
|
||||
// InterfaceHint 关联提示信息(例如接口/线路标识),用于定位设备来源。
|
||||
InterfaceHint string `gorm:"size:256" json:"interface_hint"`
|
||||
// TimeWindowsJSON 以 JSON 文本形式描述规则生效时间窗口。
|
||||
TimeWindowsJSON string `gorm:"type:text" json:"time_windows_json"`
|
||||
}
|
||||
|
||||
func (TrapShield) TableName() string {
|
||||
|
||||
Reference in New Issue
Block a user