2026-06-26 12:51:50 +08:00
|
|
|
|
package models
|
|
|
|
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
|
|
|
|
|
// TrapDictionaryEntry 表示 Trap 字典条目,用于描述某个 OID 前缀对应的告警元信息。
|
|
|
|
|
|
type TrapDictionaryEntry struct {
|
|
|
|
|
|
// 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"`
|
|
|
|
|
|
// Vendor 表示设备厂商,例如 H3C、Huawei、Cisco。
|
|
|
|
|
|
Vendor string `gorm:"size:128;index" json:"vendor"`
|
|
|
|
|
|
// OID 表示精确 Trap OID。为空时继续使用 OIDPrefix 做前缀匹配。
|
|
|
|
|
|
OID string `gorm:"size:512;index" json:"oid"`
|
|
|
|
|
|
// Name 表示 Trap 字典名称;保留 Title 作为旧页面兼容字段。
|
|
|
|
|
|
Name string `gorm:"size:512" json:"name"`
|
|
|
|
|
|
// 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"`
|
|
|
|
|
|
// SeverityMappingJSON 保存按 varbind 或厂商级别映射到平台级别的 JSON。
|
|
|
|
|
|
SeverityMappingJSON string `gorm:"type:text" json:"severity_mapping_json"`
|
|
|
|
|
|
// ParseExpression 表示解析 varbind 的表达式或正则模板。
|
|
|
|
|
|
ParseExpression string `gorm:"type:text" json:"parse_expression"`
|
|
|
|
|
|
// RecoveryMessage 表示恢复/消警时的消息模板内容。
|
|
|
|
|
|
RecoveryMessage string `gorm:"type:text" json:"recovery_message"`
|
|
|
|
|
|
// Enabled 表示该字典条目是否启用。
|
|
|
|
|
|
Enabled bool `gorm:"default:true" json:"enabled"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (TrapDictionaryEntry) TableName() string {
|
|
|
|
|
|
return "logs_trap_dictionary"
|
|
|
|
|
|
}
|