models

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	ID         string                      `gorm:"primaryKey" json:"id"`                  // 探针ID (UUID)
	Name       string                      `gorm:"index" json:"name"`                     // 探针名称
	Hostname   string                      `gorm:"index" json:"hostname,omitempty"`       // 主机名
	IP         string                      `gorm:"index" json:"ip,omitempty"`             // 连接 IP 地址
	IPv4       string                      `gorm:"index" json:"ipv4,omitempty"`           // 公网 IPv4 地址
	IPv6       string                      `gorm:"index" json:"ipv6,omitempty"`           // 公网 IPv6 地址
	OS         string                      `json:"os"`                                    // 操作系统
	Arch       string                      `json:"arch"`                                  // 架构
	Version    string                      `json:"version"`                               // 探针版本
	Tags       datatypes.JSONSlice[string] `json:"tags"`                                  // 标签
	ExpireTime int64                       `json:"expireTime"`                            // 到期时间(时间戳毫秒)
	Status     int                         `json:"status"`                                // 状态: 0-离线, 1-在线
	Visibility string                      `gorm:"default:public" json:"visibility"`      // 可见性: public-匿名可见, private-登录可见
	Weight     int                         `gorm:"default:0;index" json:"weight"`         // 权重排序(数字越大越靠前)
	Remark     string                      `json:"remark"`                                // 备注信息
	LastSeenAt int64                       `gorm:"index" json:"lastSeenAt"`               // 最后上线时间(时间戳毫秒)
	CreatedAt  int64                       `json:"createdAt"`                             // 创建时间(时间戳毫秒)
	UpdatedAt  int64                       `json:"updatedAt" gorm:"autoUpdateTime:milli"` // 更新时间(时间戳毫秒)

	// 流量统计相关字段
	TrafficStats datatypes.JSONType[TrafficStatsData] `json:"trafficStats,omitempty"` // 流量统计

	// 防篡改保护配置
	TamperProtectConfig datatypes.JSONType[TamperProtectConfigData] `json:"tamperProtectConfig,omitempty"` // 防篡改保护配置

	// SSH登录监控配置
	SSHLoginConfig datatypes.JSONType[SSHLoginConfigData] `json:"sshLoginConfig,omitempty"` // SSH登录监控配置
}

Agent 探针信息

func (Agent) TableName

func (Agent) TableName() string

type AgentInstallConfig added in v0.1.5

type AgentInstallConfig struct {
	ServerURL string `json:"serverUrl"` // 服务端地址
}

AgentInstallConfig 探针安装配置

type AlertConfig

type AlertConfig struct {
	Enabled       bool               `json:"enabled"`       // 是否启用全局告警
	MaskIP        bool               `json:"maskIP"`        // 是否在通知中打码 IP 地址
	Rules         AlertRules         `json:"rules"`         // 告警规则
	Notifications AlertNotifications `json:"notifications"` // 通知开关
}

AlertConfig 全局告警配置

type AlertNotifications added in v0.1.1

type AlertNotifications struct {
	TrafficEnabled         bool `json:"trafficEnabled"`         // 流量告警通知
	SSHLoginSuccessEnabled bool `json:"sshLoginSuccessEnabled"` // SSH 登录成功通知
	TamperEventEnabled     bool `json:"tamperEventEnabled"`     // 防篡改事件通知
}

AlertNotifications 告警通知开关

type AlertRecord

type AlertRecord struct {
	ID            int64   `gorm:"primaryKey;autoIncrement" json:"id"`    // 记录ID
	AgentID       string  `gorm:"index" json:"agentId"`                  // 探针ID
	AgentName     string  `json:"agentName"`                             // 探针名称
	AlertType     string  `json:"alertType"`                             // 告警类型: cpu, memory, disk, network
	Message       string  `json:"message"`                               // 告警消息
	Threshold     float64 `json:"threshold"`                             // 告警阈值
	ActualValue   float64 `json:"actualValue"`                           // 告警触发时的实际值
	ResolvedValue float64 `json:"resolvedValue,omitempty"`               // 恢复时的实际值
	Level         string  `json:"level"`                                 // 告警级别: info, warning, critical
	Status        string  `json:"status"`                                // 状态: firing(告警中), resolved(已恢复)
	FiredAt       int64   `gorm:"index" json:"firedAt"`                  // 触发时间(时间戳毫秒)
	ResolvedAt    int64   `json:"resolvedAt,omitempty"`                  // 恢复时间(时间戳毫秒)
	CreatedAt     int64   `json:"createdAt"`                             // 创建时间(时间戳毫秒)
	UpdatedAt     int64   `json:"updatedAt" gorm:"autoUpdateTime:milli"` // 更新时间(时间戳毫秒)
}

AlertRecord 告警记录

func (AlertRecord) TableName

func (AlertRecord) TableName() string

type AlertRules

type AlertRules struct {
	// CPU 告警配置
	CPUEnabled   bool    `json:"cpuEnabled"`   // 是否启用CPU告警
	CPUThreshold float64 `json:"cpuThreshold"` // CPU使用率阈值(0-100)
	CPUDuration  int     `json:"cpuDuration"`  // 持续时间(秒)

	// 内存告警配置
	MemoryEnabled   bool    `json:"memoryEnabled"`   // 是否启用内存告警
	MemoryThreshold float64 `json:"memoryThreshold"` // 内存使用率阈值(0-100)
	MemoryDuration  int     `json:"memoryDuration"`  // 持续时间(秒)

	// 磁盘告警配置
	DiskEnabled   bool    `json:"diskEnabled"`   // 是否启用磁盘告警
	DiskThreshold float64 `json:"diskThreshold"` // 磁盘使用率阈值(0-100)
	DiskDuration  int     `json:"diskDuration"`  // 持续时间(秒)

	// 网络告警配置
	NetworkEnabled   bool    `json:"networkEnabled"`   // 是否启用网络告警
	NetworkThreshold float64 `json:"networkThreshold"` // 网速阈值(MB/s)
	NetworkDuration  int     `json:"networkDuration"`  // 持续时间(秒)

	// HTTPS 证书告警配置
	CertEnabled   bool    `json:"certEnabled"`   // 是否启用证书告警
	CertThreshold float64 `json:"certThreshold"` // 证书剩余天数阈值

	// 服务下线告警配置
	ServiceEnabled  bool `json:"serviceEnabled"`  // 是否启用服务下线告警
	ServiceDuration int  `json:"serviceDuration"` // 持续时间(秒)

	// 探针离线告警配置
	AgentOfflineEnabled  bool `json:"agentOfflineEnabled"`  // 是否启用探针离线告警
	AgentOfflineDuration int  `json:"agentOfflineDuration"` // 持续时间(秒)
}

AlertRules 告警规则

type AlertState

type AlertState struct {
	ID            string  `gorm:"primaryKey" json:"id"`                  // 状态ID(格式:agentId:configId:alertType)
	AgentID       string  `gorm:"index" json:"agentId"`                  // 探针ID
	AlertType     string  `gorm:"index" json:"alertType"`                // 告警类型
	Value         float64 `json:"value"`                                 // 当前值
	Threshold     float64 `json:"threshold"`                             // 阈值
	StartTime     int64   `json:"startTime"`                             // 开始超过阈值的时间
	Duration      int     `json:"duration"`                              // 需要持续的时间(秒)
	LastCheckTime int64   `json:"lastCheckTime"`                         // 上次检查时间
	IsFiring      bool    `json:"isFiring"`                              // 是否正在告警
	LastRecordID  int64   `json:"lastRecordId"`                          // 最后一条告警记录ID
	CreatedAt     int64   `json:"createdAt"`                             // 创建时间(时间戳毫秒)
	UpdatedAt     int64   `json:"updatedAt" gorm:"autoUpdateTime:milli"` // 更新时间(时间戳毫秒)
}

AlertState 告警状态(持久化到数据库,用于判断是否持续超过阈值)

func (AlertState) TableName

func (AlertState) TableName() string

type ApiKey

type ApiKey struct {
	ID        string `gorm:"primaryKey" json:"id"`                  // 密钥ID (UUID)
	Name      string `gorm:"index" json:"name"`                     // 密钥名称/备注
	Key       string `gorm:"uniqueIndex" json:"key"`                // API密钥
	Enabled   bool   `gorm:"index;default:true" json:"enabled"`     // 是否启用
	CreatedBy string `gorm:"index" json:"createdBy"`                // 创建人ID
	CreatedAt int64  `json:"createdAt"`                             // 创建时间(时间戳毫秒)
	UpdatedAt int64  `json:"updatedAt" gorm:"autoUpdateTime:milli"` // 更新时间(时间戳毫秒)
}

ApiKey API密钥信息

func (ApiKey) TableName

func (ApiKey) TableName() string

type AuditResult

type AuditResult struct {
	ID        int64  `gorm:"primaryKey;autoIncrement" json:"id"`
	AgentID   string `gorm:"type:varchar(64);not null;index" json:"agentId"`
	Type      string `gorm:"type:varchar(32);not null" json:"type"` // vps_audit
	Result    string `gorm:"type:text;not null" json:"result"`      // JSON格式的审计结果
	StartTime int64  `gorm:"not null" json:"startTime"`
	EndTime   int64  `gorm:"not null" json:"endTime"`
	CreatedAt int64  `gorm:"not null" json:"createdAt"`
}

AuditResult 审计结果模型

func (AuditResult) TableName

func (AuditResult) TableName() string

TableName 表名

type DDNSConfig

type DDNSConfig struct {
	ID       string `gorm:"primaryKey" json:"id"` // 配置ID (UUID)
	AgentID  string `json:"agentId"`              // 探针ID
	Name     string `json:"name"`                 // 配置名称
	Enabled  bool   `json:"enabled"`              // 是否启用
	Provider string `json:"provider"`             // DNS服务商类型: aliyun, tencentcloud, cloudflare, huaweicloud

	// 域名配置(IPv4 和 IPv6 分开)
	DomainsIPv4 datatypes.JSONSlice[string] `json:"domainsIpv4"` // IPv4 域名列表
	DomainsIPv6 datatypes.JSONSlice[string] `json:"domainsIpv6"` // IPv6 域名列表

	// IP 获取配置
	EnableIPv4    bool   `json:"enableIpv4"`             // 是否启用 IPv4
	EnableIPv6    bool   `json:"enableIpv6"`             // 是否启用 IPv6
	IPv4GetMethod string `json:"ipv4GetMethod"`          // IPv4 获取方式: api, interface
	IPv6GetMethod string `json:"ipv6GetMethod"`          // IPv6 获取方式: api, interface
	IPv4GetValue  string `json:"ipv4GetValue,omitempty"` // IPv4 获取配置值(接口名/API URL)
	IPv6GetValue  string `json:"ipv6GetValue,omitempty"` // IPv6 获取配置值(接口名/API URL)

	CreatedAt int64 `json:"createdAt"`                             // 创建时间(时间戳毫秒)
	UpdatedAt int64 `json:"updatedAt" gorm:"autoUpdateTime:milli"` // 更新时间(时间戳毫秒)
}

DDNSConfig DDNS 配置

func (DDNSConfig) TableName

func (DDNSConfig) TableName() string

type DDNSRecord

type DDNSRecord struct {
	ID           string `gorm:"primaryKey" json:"id"`   // 记录ID
	ConfigID     string `gorm:"index" json:"configId"`  // 配置ID
	AgentID      string `gorm:"index" json:"agentId"`   // 探针ID
	Domain       string `gorm:"index" json:"domain"`    // 域名
	RecordType   string `json:"recordType"`             // 记录类型: A, AAAA
	OldIP        string `json:"oldIp,omitempty"`        // 旧IP
	NewIP        string `json:"newIp"`                  // 新IP
	Status       string `json:"status"`                 // 更新状态: success, failed
	ErrorMessage string `json:"errorMessage,omitempty"` // 错误信息
	CreatedAt    int64  `gorm:"index" json:"createdAt"` // 创建时间(时间戳毫秒)
}

DDNSRecord DDNS 更新记录

func (DDNSRecord) TableName

func (DDNSRecord) TableName() string

type DNSProviderConfig

type DNSProviderConfig struct {
	Provider string                 `json:"provider"` // 服务商类型: aliyun, tencentcloud, cloudflare, huaweicloud
	Enabled  bool                   `json:"enabled"`  // 是否启用
	Config   map[string]interface{} `json:"config"`   // 配置对象(敏感信息)
}

DNSProviderConfig DNS 服务商配置(存储在 Property 中)

type MonitorTask

type MonitorTask struct {
	ID               string                                         `gorm:"primaryKey" json:"id"`                  // 任务 ID
	Name             string                                         `gorm:"uniqueIndex" json:"name"`               // 任务名称
	Type             string                                         `gorm:"index" json:"type"`                     // 监控类型 http/tcp
	Target           string                                         `json:"target"`                                // 目标地址
	Description      string                                         `json:"description"`                           // 描述信息
	Enabled          bool                                           `json:"enabled"`                               // 是否启用
	ShowTargetPublic bool                                           `json:"showTargetPublic"`                      // 在公开页面是否显示目标地址
	Visibility       string                                         `gorm:"default:public" json:"visibility"`      // 可见性: public-匿名可见, private-登录可见
	Interval         int                                            `json:"interval"`                              // 检测频率(秒),默认 60
	AgentIds         datatypes.JSONSlice[string]                    `json:"agentIds"`                              // 指定的探针 ID 列表(JSON 数组)
	AgentNames       []string                                       `gorm:"-" json:"agentNames"`                   // 指定的探针名称列表
	HTTPConfig       datatypes.JSONType[protocol.HTTPMonitorConfig] `json:"httpConfig"`                            // HTTP 监控配置
	TCPConfig        datatypes.JSONType[protocol.TCPMonitorConfig]  `json:"tcpConfig"`                             // TCP 监控配置
	ICMPConfig       datatypes.JSONType[protocol.ICMPMonitorConfig] `json:"icmpConfig"`                            // ICMP 监控配置
	CreatedAt        int64                                          `gorm:"autoCreateTime:milli" json:"createdAt"` // 创建时间
	UpdatedAt        int64                                          `gorm:"autoUpdateTime:milli" json:"updatedAt"` // 更新时间
}

MonitorTask 描述一个服务监控任务

func (MonitorTask) TableName

func (MonitorTask) TableName() string

type NotificationChannelConfig

type NotificationChannelConfig struct {
	Type    string                 `json:"type"`    // 类型: dingtalk, wecom, feishu, webhook
	Enabled bool                   `json:"enabled"` // 是否启用
	Config  map[string]interface{} `json:"config"`  // 配置对象
}

NotificationChannelConfig 通知渠道配置(存储在 Property 中)

type Property

type Property struct {
	ID        string `gorm:"primaryKey" json:"id"`                  // 属性ID (如: notification_channels)
	Name      string `json:"name"`                                  // 可读名称
	Value     string `json:"value" gorm:"type:text"`                // JSON配置
	CreatedAt int64  `json:"createdAt"`                             // 创建时间(时间戳毫秒)
	UpdatedAt int64  `json:"updatedAt" gorm:"autoUpdateTime:milli"` // 更新时间(时间戳毫秒)
}

Property 通用属性配置表

func (Property) TableName

func (Property) TableName() string

type PublicIPConfig added in v0.1.2

type PublicIPConfig struct {
	Enabled         bool     `json:"enabled"`         // 是否启用采集
	IntervalSeconds int      `json:"intervalSeconds"` // 采集间隔(秒)
	IPv4Scope       string   `json:"ipv4Scope"`       // IPv4 采集范围: all/custom
	IPv4AgentIDs    []string `json:"ipv4AgentIds"`    // IPv4 自定义探针列表
	IPv6Scope       string   `json:"ipv6Scope"`       // IPv6 采集范围: all/custom
	IPv6AgentIDs    []string `json:"ipv6AgentIds"`    // IPv6 自定义探针列表
	IPv4Enabled     bool     `json:"ipv4Enabled"`     // 是否采集 IPv4
	IPv6Enabled     bool     `json:"ipv6Enabled"`     // 是否采集 IPv6
	IPv4APIs        []string `json:"ipv4Apis"`        // IPv4 API 列表
	IPv6APIs        []string `json:"ipv6Apis"`        // IPv6 API 列表
}

PublicIPConfig 公网 IP 采集配置

func (*PublicIPConfig) IsIPv4Target added in v0.1.2

func (c *PublicIPConfig) IsIPv4Target(agentID string) bool

func (*PublicIPConfig) IsIPv6Target added in v0.1.2

func (c *PublicIPConfig) IsIPv6Target(agentID string) bool

type SSHLoginConfigData added in v0.1.1

type SSHLoginConfigData struct {
	Enabled      bool     `json:"enabled"`                // 是否启用
	IPWhitelist  []string `json:"ipWhitelist,omitempty"`  // IP白名单,白名单中的IP只记录不发送通知,支持 IP 或 CIDR
	ApplyStatus  string   `json:"applyStatus,omitempty"`  // 配置应用状态: success/failed/pending
	ApplyMessage string   `json:"applyMessage,omitempty"` // 应用结果消息
}

SSHLoginConfigData SSH登录监控配置数据

func (SSHLoginConfigData) IsIPWhitelisted added in v0.1.1

func (r SSHLoginConfigData) IsIPWhitelisted(ip string) bool

type SSHLoginEvent added in v0.1.1

type SSHLoginEvent struct {
	ID         string `gorm:"primaryKey" json:"id"`              // 事件ID (UUID)
	AgentID    string `gorm:"index;not null" json:"agentId"`     // 探针ID
	Username   string `gorm:"index" json:"username"`             // 用户名
	IP         string `gorm:"index" json:"ip"`                   // 来源IP
	IPLocation string `gorm:"index" json:"ipLocation,omitempty"` // IP归属地
	Port       string `json:"port,omitempty"`                    // 来源端口
	Status     string `gorm:"index" json:"status"`               // 状态: success
	TTY        string `json:"tty,omitempty"`                     // 终端
	SessionID  string `json:"sessionId,omitempty"`               // 会话ID
	Timestamp  int64  `gorm:"index" json:"timestamp"`            // 登录时间(毫秒时间戳)
	CreatedAt  int64  `json:"createdAt"`                         // 记录创建时间(毫秒)
}

SSHLoginEvent SSH登录事件

func (SSHLoginEvent) TableName added in v0.1.1

func (SSHLoginEvent) TableName() string

type SystemConfig

type SystemConfig struct {
	SystemNameZh string `json:"systemNameZh"` // 系统名称(中文)
	SystemNameEn string `json:"systemNameEn"` // 系统名称(英文)
	LogoBase64   string `json:"logoBase64"`   // 系统logo(base64编码)
	ICPCode      string `json:"icpCode"`      // ICP备案号
	DefaultView  string `json:"defaultView"`  // 默认视图 grid | list
	CustomCSS    string `json:"customCSS"`    // 自定义 CSS
	CustomJS     string `json:"customJS"`     // 自定义 JS
	Version      string `json:"-"`            // 系统版本
}

type TamperEvent

type TamperEvent struct {
	ID        string `gorm:"primaryKey" json:"id"`          // 事件ID (UUID)
	AgentID   string `gorm:"index;not null" json:"agentId"` // 探针ID
	Path      string `gorm:"index" json:"path"`             // 被修改的路径
	Operation string `json:"operation"`                     // 操作类型: write, remove, rename, chmod, create
	Details   string `json:"details"`                       // 详细信息
	Timestamp int64  `gorm:"index" json:"timestamp"`        // 事件时间(时间戳毫秒)
	CreatedAt int64  `json:"createdAt"`                     // 记录创建时间(时间戳毫秒)
}

TamperEvent 防篡改事件

func (TamperEvent) TableName

func (TamperEvent) TableName() string

type TamperProtectConfigData added in v0.1.1

type TamperProtectConfigData struct {
	Enabled      bool     `json:"enabled"`                // 是否启用
	Paths        []string `json:"paths"`                  // 受保护的目录列表
	ApplyStatus  string   `json:"applyStatus,omitempty"`  // 配置应用状态: success/failed/pending
	ApplyMessage string   `json:"applyMessage,omitempty"` // 应用结果消息
}

TamperProtectConfigData 防篡改保护配置数据

type TrafficStatsData added in v0.1.1

type TrafficStatsData struct {
	Enabled      bool   `json:"enabled"`      // 是否启用
	Type         string `json:"type"`         // 统计类型: "recv"进站, "send"出站, "both"全部
	Limit        uint64 `json:"limit"`        // 流量限额(字节), 0表示不限制
	Used         uint64 `json:"used"`         // 当前周期已使用流量(字节)
	UsedOffset   uint64 `json:"usedOffset"`   // 基线调整使用偏移(字节)
	ResetDay     int    `json:"resetDay"`     // 流量重置日期(1-31), 0表示不自动重置
	PeriodStart  int64  `json:"periodStart"`  // 当前周期开始时间(时间戳毫秒)
	BaselineRecv uint64 `json:"baselineRecv"` // 当前周期流量基线(BytesRecvTotal)
	BaselineSend uint64 `json:"baselineSend"` // 当前周期流量基线(BytesSentTotal)
	AlertSent80  bool   `json:"alertSent80"`  // 是否已发送80%告警
	AlertSent90  bool   `json:"alertSent90"`  // 是否已发送90%告警
	AlertSent100 bool   `json:"alertSent100"` // 是否已发送100%告警
}

TrafficStatsData 流量统计数据

type WebhookConfig

type WebhookConfig struct {
	URL        string            `json:"url"`                  // Webhook URL
	Method     string            `json:"method,omitempty"`     // 请求方法,默认 POST
	Headers    map[string]string `json:"headers,omitempty"`    // 自定义请求头
	CustomBody string            `json:"customBody,omitempty"` // 自定义请求体模板(支持变量)
}

WebhookConfig 自定义 Webhook 配置结构

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL